> For the complete documentation index, see [llms.txt](https://docs.videsk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.videsk.io/es-developers/widgets/api/variables-globales.md).

# Variables globales

Actualmente para acceder al widget existen dos variables globales que puedes usar:

* `window.videsk`
* `videsk`

El problema de estas variables globales, es que están disponibles solo una vez que el widget está totalmente cargado, lo que podría provocar errores de variables globales indefinidas.

Para ellos disponemos de variables globales que el widget observa antes de cargar con el objetivo de modificar su comportamiento por defecto.

Estas son:

#### Iniciar oculto

```
window.__VIDESK_WIDGET_START_HIDE__
```

Esta variable global al estar con el valor en `true`, permite que el widget inicio totalmente oculto.

#### Inicio diferido

```
window.__VIDESK_LOAD_DEFERER__
```

Esta variable global al estar con el valor en true, permite que el widget no se cargue hasta ejecutar el método `render`.

## ¿Cómo ocultar el widget?

Para ocultar el widget, durante la carga, debes añadir en tú sitio y antes del `script` de Videsk Widget la siguiente variable global:

{% hint style="warning" %}
Esta acción es para ocultar completamente el widget. Es decir, cuerpo y burbuja flotante.

**Se recomienda en caso de requerir accionar la visibilidad desde un componente del sitio.**
{% endhint %}

{% tabs %}
{% tab title="Global var" %}

```javascript
// This before script !!
window.__VIDESK_WIDGET_START_HIDE__ = true;

<script src="..." videsk-token="..." async></script>
```

{% endtab %}

{% tab title="Onload" %}

```javascript
// This before script !!

window.__VIDESK_WIDGET_ONLOAD__ = function() {
    videsk.toggleVisibility(true || false)
}

<script src="..." videsk-token="..." async></script>
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Recuerda que para acceder a la API del Widget es mediante la variable global `videsk`
{% endhint %}

## Carga diferida

La carga diferida es recomendada para sitios web de alto tráfico o temporadas hot sales. Te sugerimos añadir este comportamiento basado en clics de elementos externos como botones personalizados, banners, etc.

{% hint style="warning" %}
El siguiente código **deberás añadirlo antes de cargar el widget**.
{% endhint %}

```javascript
window.__VIDESK_LOAD_DEFERER__ = true;

// Load widget script ....
// After widget script ...
document.querySelector('#my-button').addEventListener('click', async () => {
  if (!window.videsk) return;
  await videsk.render();
  videsk.toggle();
});
```

De esta manera cargarás solo el widget cuando un cliente interactúe mediante un clic con un elemento personalizado.

{% hint style="danger" %}
Por calidad de servicio, si detectamos altos picos de tráficos podemos bloquear la carga en tu sitio web hasta que apliques esta estrategia.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.videsk.io/es-developers/widgets/api/variables-globales.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
