The “Delayed Scripts” feature allows you to tell NitroPack which scripts to load with a delay.
A delayed script will execute about 6500ms after the page finishes loading. This helps give loading priority to your other scripts that may be more important for the user experience.
For example, you may want to delay the execution of a chat widget on your site.
- Entering the script’s URL (for external scripts)
- Writing down a single line of code that’s unique to the resource (for inline scripts)
Important note: When delaying an inline script, don’t enter the script tag in the “Script URL/Code” field.
For example, to delay this script:
Skip the <script> tag.
And choose one line of code that’s unique to the snippet.
You can use the wildcard symbol * to match more than one resource with a single rule or to avoid writing the entire snippet.
In our example, we can delay the script by entering document*cta-btn instead of the entire line of code.
If you have resources with dynamic parts in them (like dynamic URLs), you can also use the wildcard to match their dynamic parts.
Once you fill out all the fields, remember to save your settings.