Delay JS
"Delay JS" works a bit differently from "defer." When you use delay JS, the JavaScript execution is postponed until after a specific event occurs, in our case when the user interacts with the page (like scrolling, clicking, or typing). This technique ensures that the page loads even faster because the JavaScript doesn't run immediately when the page is loading. Instead, it waits until the user starts engaging with the page.
In Super Page Cache, adding delay JS means the browser will load the page's visible content first, without immediately processing the JavaScript. This can further enhance performance, especially on pages with a lot of scripts, by making the page appear to load almost instantly. The JavaScript is only triggered once the user interacts with the page.
How to enable:
- Go to Super Page Cache > Settings.
- Navigate to Files tab and enable the Delay JavaScript option.
- Click on update settings to save the changes.
You can also exclude some JavaScript files or pages from this option by using the file name and page URL in the settings and saving the changes. Don't forget to purge the Cache after saving all those changes.