This optimization takes all page Javascript – both inline and external – and runs it after the page has fully loaded.
NAME | js_async_defer |
---|---|
TYPE | boolean |
DEFAULT | enabled |
Advantages
The page Javascript is no longer render-blocking. Page assets like text and images can be shown to the user much earlier, before the page functionality is initialized. This significantly improves the perceived loading speed and helps nearly all web vitals.
Possible disadvantages
If the Javascript of a particular page changes the page style (which it shouldn’t do) instead of just adding functionality, then this optimization may actually hurt the page experience. Likewise if you use document.write – unlikely, but a definite no-no – then this optimization will cause ‘jitter’ in page rendering i.e. Cumulative Layout Shift, since the re-render will take place much later.
If you have Javascript that visibly affects the page style, the best practice – other than not doing that – is to disable this optimization for that script only using the attribute ‘data-spin=false’.
It is also theoretically possible – in very rare cases – that this change would break the page functionality. If you encounter such a case, please email [email protected].