Delayed Scripts

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.

You can do that by enabling the “Delayed Scripts” feature from the General Settings panel and:

  • 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:

Example_Code3.png

 

Skip the <script> tag.

Example_Code4.png

 

And choose one line of code that’s unique to the snippet.

Delayed_Scripts_2.png

 

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.

Delayed_Scripts1.png

 

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.

Was this article helpful?
2 out of 3 found this helpful

Comments

0 comments

Please sign in to leave a comment.