You may be excluding too many scripts from being delayed, please consider reducing the exclusions to prioritize performance as per this.
In this article
What does it do?
This optimization will improve the following recommendations in PageSpeed:
- Minimize Main thread work
- Total blocking time
- First contentful paint
And may improve other Core Web Vitals as well.
You will find it on the File Optimization tab:
How does it work?
- This optimization is applied only on cached or optimized pages.
- All scripts that are present in the HTML of the page, will be delayed. Any scripts which are inserted after the page loads, or fetched indirectly from another script, cannot be delayed.
If anything breaks while using this option, you can exclude scripts in two ways:
- Checking the boxes of the plugins, themes or services within the "One-click exclusions" section.
New exclusions may appear in the above article first but added later to the One-click exclusions section, see more details here.
How to check if delaying is working
- This feature is not compatible with IE 11. Visitors using IE11 will be redirected to an uncached version of the page, with the query string ?nowprocket=1 appended to the URL.
Those URLs will appear to the site's analytics. You can read more about this in our doc.
srcattribute or not, a
type="rocketlazyloadscript"attribute will be added. This fake type value prevents the script from being executed by the browser.
- If a script already has a type value, it will be copied in a
data-rocket-typeattribute to be preserved
- The delay script adds a preload for all scripts with a
srcattribute, to make sure they are ready for the user interaction.
srcattribute is replaced by a
data-rocket-srcattribute, its value is preserved.
executedwhen the script was delayed and executed as expected, and
failedwhen the script wasn't executed by some reason.
- In Chrome and Safari, inline scripts will have a
- On user interaction, our delay script either removes the fake type, or replaces it with the original one, and the browser executes all scripts.
- The delay script is built to preserve the order and priority of the scripts on the page, taking into account attributes like
- As we discover conflicts, we will maintain a list of automatic exclusions. The automatic exclusions are linked to issues, and they are different from the One-click exclusions found here, which are optional.
- keydown: event is fired when a key is pressed.
- mouseover: event is fired at document (page) when a pointing device (such as a mouse or trackpad) is used to move the cursor onto it.
- touchmove: event is fired when one or more touch points are moved along the touch surface.
- touchstart: event is fired when one or more touch points are placed on the touch surface.