Identifies HTML script tags that don't have
When neither of those attributes are used, a script tag blocks the construction and rendering of the DOM until the script is loaded, parsed and executed. It also creates congestion on the network, messes with the resource priorities and significantly delays the rendering of the page.
As a general rule, use
defer if the order of execution matters, and use
async if it doesn't.
Learn more about improving your theme's performance.
The following examples contain code snippets that either fail or pass this check.
This example loads jQuery synchronously because inline scripts depend on it:
This example contains an alternative to synchronous jQuery. Because the script tag has a
defer attribute, jQuery is guaranteed to be loaded when DOMContentLoaded fires. This technique could be used as a first step to refactor an theme that depends on jQuery.
This example avoids jQuery.
Disabling this checkAnchor link to section titled "Disabling this check"
If you can't avoid violating the rule, you should disable the check using the comment syntax. This ensures that you intentionally disable the check for each instance.
Disabling this check isn't recommended.