Depending on the order in which the scripts are executed, this could prevent elements from being painted, delaying page rendering and affecting page interactivity.
Improving this audit can result in better Performance metrics, and drive real-world performance gains.
How does your site score on this audit?
When the browser finds a
1) Longer download times
2) Being unresponsive to user input
3) Significantly delaying the Time To Interactive (TTI) metric
If the page executes a lot of code before it's actually needed, it delays the point at which your page is fully interactive to user input, resulting in a slow or unresponsive experience.
4) Higher memory consumption
How does GTmetrix trigger this audit?
1) Implementing code-splitting
By executing fewer lines of code at the beginning of the page load process, First Paint can happen sooner.
Click here to learn more about code-splitting.
2) Removing unused code
Unused code can often be inherited from previous versions of your site, and/or imported from other modules that aren't referenced anymore.
You may also have chunks of code that used to be a part of testing but aren't needed on your production website.
Click here to learn more about removing unused code.
3) Caching your code with the PRPL pattern
Click here to learn how to preload key scripts.
b) Rendering the First Paint as soon as possible
Eliminate render-blocking resources to render the First Paint as soon as possible.
Read our blog article to learn more about how to implement these.
c) Pre-caching assets
Use service workers to fetch assets directly from the cache instead of downloading them again from the server. This allows faster downloads and execution on repeat visits.
Click here to learn more about pre-caching assets.
Read this article to learn more about code-splitting and lazy-loading.
Note that minification should be regarded as a way to fine-tune your performance rather than single-handedly boost it. Focus on the above optimizations before attempting minification.
Note: This is an expert-level optimization
Only experienced developers are advised to improve this audit.