Script Delay

Modified on: Wed, 27 Jan, 2021

Script Delay delays the loading and execution of Javascript until the primary content has loaded.

Many websites implement scripts that are vital to various features on a page which you may not want to delay and the Script Delay feature offers multiple options to assist you with exclusion rules for scripts you do not want the feature to impact.


URL Rules:


image


1. Allows you to choose how the URL rules are applied. In most cases, if you would like to exclude a specific script or URL from being delayed you will select the option “Run on all URLs Except”.


2. Using this dialogue box, You are able to input both external and inline scripts to be excluded/included, depending on your preferences.

Examples:

/file.js will match the script:


<script src="http://yourwebsite.com/js/file.js"></script>


myUniqueVar will match the script:


<script>var myUniqueVar = 'myUniqueString'</script>


3. Page Exclusions allow you to exclude specific pages and directories from being impacted by the Site Speed Accelerator.

Examples:

/ will match the the homepage.


/example.html will match http://bermuda-attractions.com/example.html


A wildcard can also be used to match directories. For example, /path/* will match any page in the path directory.



Find Delayed Scripts:

image


The Delayed Scripts tool allows you to quickly populate a list of external and inline scripts found on a specified URL that the Script Delay feature will delay. Once the list is generated, you can easily choose which scripts you wish to include in the URL rules for Script Delay by selecting Yes|No.


1. Scripts marked ‘no’ will automatically be added to the URL rules for the tool and will no longer be delayed.

2. Scripts marked ‘Yes’ will remain delayed by the Script Delay feature unless changed by the user.

You can also set script delay URL rules as follows. If you want to exclude certain URLs from script delay you can do this using 'no defer' parameters in your code. Here's some info on how to implement them:

https://developers.google.com/speed/pagespeed/service/DeferJavaScript



Loading ...