Script Timing will defer your JavaScript loading until a specified event that prioritizes the experience for your users without requiring a change to the scripts you use on your site. We offer a few configurations to get the most out of this feature. When other products offer a similar feature, it might “work” because it is breaking the site. With our configurations, you can see the same, if not more, benefit with the ability to do it safely and not break any portion of your website. This enhancement cannot be used alongside Rocket Loader and should be used in replacement of Rocket Loader.
How to configure
While configuring the Script Timing enhancement, you’ll want to first decide where on your website you would like this to run. Oftentimes you’ll want to enable it for all pages but our Page Speed product allows you to configure it by URL Pattern if you desire. Once you have created a URL Pattern, you’ll want to choose the event at which your JavaScript will run. We offer three settings:
Ready
This option is the safest in terms of the possible negative impact it could have on your site. This will wait for the Document Ready event to run your JavaScript. This option will have less drastic improvements on your page speed performance.
Load
This is our default event which we feel gives the most improvement in the safest way possible. This will wait for the Document Load event which will make that initial render very quick which will improve your user’s experience and your page speed scores.
Late
This is our most aggressive run event which yields the highest page speed improvement but has a slightly higher risk of causing an issue with your site. This will wait one second after the Document Load event. If you choose this event you will want to make sure you test the results to be sure you are getting the outcome you desire.
Once you have chosen your run event, you’ll want to consider if you need to blacklist any JavaScript sources. This is especially advantageous if there is a particular dependency you know needs to run at its normal time. Some you might know beforehand but others you might discover as you activate and test this enhancement. If you notice any JavaScript errors in the browser console, you can identify the dependency and blacklist it so it gets ignored from being deferred.
With these mechanisms, you can configure Script Timing on various parts of your site with various configurations so you can get the most improvement and avoid any possible negative side effects.