Book a call Free rebuild
Home/Glossary/Performance/Asynchronous Loading

Asynchronous Loading

November 5, 2022 Updated November 16, 2026 2 min read

Performance glossaryAsynchronous loading lets the browser download a script or other resource without stopping the rest of the page from loading and rendering.

Asynchronous loading means the browser fetches a resource alongside everything else instead of stopping to wait for it. The opposite, synchronous loading, makes the browser finish one thing before it moves on to the next. On the web the term almost always refers to JavaScript, because an ordinary script tag is synchronous by default.

Why ordinary scripts block the page

When the HTML parser meets a <script src="..."> tag with no extra attributes, it stops. The browser downloads the script, runs it, and only then carries on reading the HTML. Scripts behave this way because they are allowed to change the document while it is being built, for example with document.write().

A slow or large script in the <head> therefore delays everything below it, and the page stays blank while the browser waits. Lighthouse and PageSpeed Insights report these scripts as render-blocking resources.

Async and defer

HTML gives scripts two attributes that load them without blocking the parser:

  • async: the script downloads in the background and runs as soon as it arrives, pausing the parser only while it runs. Async scripts run in whatever order they finish downloading.
  • defer: the script downloads in the background and runs only after the HTML has been fully parsed, in the order the scripts appear in the page. See defer JavaScript.

Use async for independent scripts that nothing else relies on, such as analytics or ad tags. Use defer for scripts that depend on each other or on the finished page, such as a theme's menu script that needs jQuery. JavaScript modules (type="module") are deferred by default.

Asynchronous loading beyond scripts

  • Images and iframes can wait until they are near the viewport with loading="lazy", which WordPress adds to most images automatically.
  • Stylesheets are render-blocking by design. Non-critical CSS can be loaded later, but the CSS for what appears first should arrive with the page.
  • Data requested with JavaScript, through fetch() or AJAX, loads asynchronously, so the page can appear first and fill in content afterward.

Asynchronous scripts in WordPress

Themes and plugins should load scripts through wp_enqueue_script(), which accepts a loading strategy. Passing 'strategy' => 'async' or 'strategy' => 'defer' in its arguments array makes WordPress add the attribute, and WordPress checks the scripts that depend on it so nothing runs out of order. Optimization plugins can also add async or defer to scripts they did not write, which is where most problems start.

Common mistakes

  • Making a library such as jQuery async while other scripts, or inline code in the page, need it first. The result is "jQuery is not defined" errors and broken menus, sliders, or forms.
  • Assuming async scripts run in order. They do not; use defer when order matters.
  • Lazy-loading the main image at the top of the page, which delays Largest Contentful Paint.
  • Skipping the retest. After any change to how scripts load, check key pages, forms, and the browser console for errors.

Source: MDN: the script element.

WP Services

WordPress services at revolutionary pricing.

Productized WordPress services, from builds to care, delivered by Seahawk and tracked in one app. For the WordPress lovers.