Defer vs Async Attributes & Their Impact On Performance
Have you ever looked up how to improve the load time of your website and been told to defer the JavaScript (JS) or load it with asynchronously? Do you have any idea what that means? Each method is similar, however there are distinct differences you need to know about.
Loading JavaScript in a non-render blocking way is quintessential in optimizing your website, especially for mobile devices. Many performance tests such as GTmetrix, Pingdom, or Google Page Speed Insights will tell you to defer the Javascript to the footer.
Services like Google AdSense or various tracking codes are loaded with the asynchronous (async) tag. These services do not impact your website's performance.
What Does The Defer Attribute Do?
The Defer attribute, like the async attribute, affects the way that your browser interacts with JavaScript files. The defer attribute downloads the JavaScript files at the same time the HTML is being parsed.
However, the file will only be executed after all the HTML has been parsed. Additionally deferred JavaScript files will always execute in the order that they appear in the document. This is useful to know in scenarios where you are not combining the JavaScript files.
What Does The Async Attribute Do?
The asynchronous (async) attribute is the younger and newer version of the defer attribute. The defer attribute is like the async attribute. This is because the async attribute will download the JavaScript file while the HTML file is being parsed. The difference with async is that it pauses the HTML parser when the JavaScript file is finished being downloaded so the JavaScript file can be executed. This circumvents the render blocking of a plain old script tag, the HTML parser will still be interrupted.
So What Does This Mean For Performance?
If you have JavaScript files that deliver a fairly large payload, such as an advertising network, then deferring the JavaScript until the document is ready will allow the document's HTML to be parsed. It will be ready before delivering a large amount of images, video, JavaScript, etc.
Essentially, "the most performant way" to include JavaScript is to load it in the footer with the defer tag (when available you can't always do this).
Scott Hartley
Founder & CEO, Sert Media
Founder and CEO of Sert Media, a Nashville-based digital marketing agency. Scott has spent over 15 years helping businesses grow through SEO, web performance optimization, and strategic digital marketing. His deep expertise in WordPress development, site speed, and technical SEO has guided hundreds of brands toward measurable results. When he's not auditing Core Web Vitals or refining campaign strategies, he's writing about the tools, techniques, and trends shaping the modern web.
Related Articles
Content Marketing ROI Measurement
Every team hears the same thing from leaders: "What's the return on our content spend?"…
Paid Media Budget Allocation Framework
Your marketing team already knows paid media is worth the investment. The real question is…
Complete Guide to Technical SEO Audits
Technical SEO is the foundation all other search efforts rest on. Without a solid technical…