> For the complete documentation index, see [llms.txt](https://help.twinr.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.twinr.dev/screen-customization/apply-custom-javascript.md).

# Custom JS

Run your own JavaScript on your app's screens.

Custom JS injects JavaScript into your pages when they are shown inside the app. It runs on both iOS and Android, and you choose which screens it applies to.

The common use is calling the Twinr JS Bridge — asking for a push token, opening the barcode scanner, triggering a review prompt — without editing your website.

{% content-ref url="/pages/2hGcX74M7AUT3Clgs7ix" %}
[What is the JS Bridge?](https://help.twinr.dev/js-bridge/what-is-the-js-bridge.md)
{% endcontent-ref %}

Open **General Settings → Scripts**.

## When your script runs

Choose one of three timings:

<table><thead><tr><th width="230">Timing</th><th>When it runs</th></tr></thead><tbody><tr><td><strong>At Document Start</strong></td><td>As the page begins loading, before the content is there. Use it to set something up ahead of the page.</td></tr><tr><td><strong>At Document End</strong></td><td>Once the page has fully loaded. Use it when your script needs to find elements on the page.</td></tr><tr><td><strong>Continuously</strong></td><td>Keeps running. Use it only when you must react to ongoing changes.</td></tr></tbody></table>

{% hint style="info" %}
**At Document End is the usual choice.** A script that looks for an element and runs at Document Start will find nothing, because the page has not been built yet.
{% endhint %}

{% hint style="warning" %}
**Continuously is expensive.** A script that never stops costs battery and can make scrolling stutter. Reach for it only when the other two genuinely cannot do the job.
{% endhint %}

Pick the screens it applies to, then click **Save as draft**.

## Common Questions

<details>

<summary>My script does nothing.</summary>

Most often it runs at Document Start and the element it needs does not exist yet. Switch to Document End.

</details>

<details>

<summary>Can I use this instead of editing my website?</summary>

Yes — that is the point. Anything you would add to your site's pages can be injected here instead, which is useful when you cannot easily change the site.

</details>

<details>

<summary>Will it run in the browser too?</summary>

No. These scripts are injected by the app only. Visitors on the web are unaffected.

</details>
