Fixing Render-Blocking CSS and JavaScript in WordPress
How to cut the CSS and JavaScript that hold up the first paint in WordPress: remove unused assets per page, defer scripts with the core loading strategies, and avoid the settings that break sites.

A browser will not draw a page until it has downloaded and processed every stylesheet in the head, and it stops reading the HTML each time it meets an ordinary script tag. On a WordPress site those files come from the theme and from every plugin that adds something to the front end, so a long queue ahead of the first paint is normal.
Fixing render-blocking resources in WordPress means doing three things in order: load fewer files, defer the scripts that remain, and keep the CSS needed for the first screen small. Optimization plugins automate parts of this. They are also the usual way sites get broken, so it helps to know what each switch does.
What blocks rendering and what does not
Stylesheets linked in the head block rendering, because the browser will not show unstyled content. Scripts block the HTML parser unless told otherwise, and how a script is loaded decides the cost:
| How the script is loaded | Blocks the parser | When it runs | Order kept |
|---|---|---|---|
| Plain script in the head | Yes, while it downloads and runs | Immediately | Yes |
| Plain script before the closing body tag | No, the content above is already parsed | When the parser reaches it | Yes |
With defer | No | After the HTML is parsed | Yes |
With async | Only at the moment it runs | As soon as it has downloaded | No |
So defer is the safe default for scripts that depend on each other, and async suits independent ones such as an analytics tag. Neither reduces the amount of JavaScript the device has to execute. They only move it out of the way of the first paint.
See what the page loads now
Before changing anything, make a list. Three tools give you one quickly:
- PageSpeed Insights lists the render-blocking requests it found and the time each cost.
- The Coverage tab in Chrome DevTools shows how much of each CSS and JavaScript file was used to draw the page. Files that are almost entirely unused here are candidates for removal.
- Query Monitor's scripts and styles panels list every enqueued file with its handle, its dependencies and whether it prints in the header or the footer. You need the handle to change how a file loads.
Do this for one page of each template: home, a post, a product, a landing page. They rarely load the same set.
Stop loading assets on pages that do not use them
The cheapest file is the one that is never requested. Plugins tend to enqueue their CSS and JavaScript on every page, because they cannot know where you will place their shortcode or block. A slider used on the home page, a form used on the contact page and a table plugin used in three posts all end up in the head of every page.
Remove them where they are not needed, from a small custom plugin or the child theme:
add_action( 'wp_enqueue_scripts', function () {
if ( is_front_page() ) {
return;
}
wp_dequeue_style( 'example-slider' );
wp_dequeue_script( 'example-slider' );
}, 100 );
Replace example-slider with the handles from Query Monitor. The priority of 100 makes the callback run after the plugin has enqueued its files. Asset manager plugins do the same job through a settings screen.
Core already does this for blocks. In block themes, and in classic themes on current WordPress versions, the CSS for a block is loaded only on pages that contain it, and small stylesheets are inlined into the page. A theme that ships one large stylesheet for everything gets none of that benefit.
Defer scripts with the loading strategies in core
Since version 6.3, WordPress has a supported way to mark a script as deferred or async when it is registered. The last argument of wp_enqueue_script() accepts an array:
wp_enqueue_script(
'site-navigation',
get_theme_file_uri( 'assets/js/navigation.js' ),
array(),
'1.4.0',
array(
'strategy' => 'defer',
'in_footer' => true,
)
);
The advantage over the old trick of rewriting script tags with a filter is that core understands dependencies. If a script that must run immediately depends on your deferred one, WordPress loads both the blocking way so that nothing runs out of order. An inline script attached after a deferred script has the same effect. That is the safe behavior, and it explains why a script you marked as deferred sometimes is not: something else in the chain needs it sooner.
For a plugin's script you do not control, the strategy can be added from outside:
add_action( 'wp_enqueue_scripts', function () {
wp_script_add_data( 'example-plugin-script', 'strategy', 'defer' );
}, 100 );
Test properly afterwards. Scripts written on the assumption that they run before the page is parsed can fail when deferred. jQuery is the classic case. Many plugins and page builders print inline snippets that call jQuery straight away, and those snippets throw errors if jQuery itself has been deferred. Leave jQuery alone unless you have checked every inline script on the site. The core dev note on script loading strategies sets out the rules in full.
Critical CSS and its side effects
Critical CSS means putting the styles needed for the first screen directly in the HTML and loading the full stylesheets without blocking. Done well, the page paints almost as soon as the HTML arrives. It is also the optimization that causes the most visible problems:
- The critical styles have to be generated per template and regenerated when the design changes. Stale critical CSS flashes the old header on every page load.
- If the inline styles do not match the full stylesheet closely, the page shifts when the rest arrives, and a loading problem has become a layout shift problem. That counts against you in Core Web Vitals.
- Variants are easy to miss: logged-in views, the mobile menu, a cookie banner, a sale ribbon.
Often there is a simpler route. Remove unused stylesheets, split a monolithic theme stylesheet so each template loads what it uses, and let core inline the small ones. Once the blocking CSS is down to a modest size, critical CSS is no longer worth its upkeep.
The risks of aggressive minify and delay settings
Performance plugins offer a row of switches, and each has a failure mode worth knowing before you turn it on.
- Combine files. Merging scripts changes their order and scope, and one syntax error stops the whole bundle. Over HTTP/2 and HTTP/3 the gain from fewer requests is small. This is the first setting to leave off.
- Delay JavaScript until interaction. Nothing runs until the visitor scrolls or taps, and lab scores improve sharply. In real use the first tap on the menu or the add-to-cart button can do nothing while every delayed script loads at once, consent banners appear late, and analytics miss visitors who leave without interacting.
- Remove unused CSS. The tool loads the page, records which selectors matched and drops the rest. Classes added later by JavaScript (an open menu, a modal, a validation error) were not on the page at that moment, and their styles disappear.
- Minify. Low risk and low reward when the files already arrive minified from their authors.
Whatever you enable, turn on one setting at a time, exclude the cart, checkout and login pages from script delay and combination, and keep the list of exclusions where the next person will find it.
Test the page as a visitor would
A better score is not the finish line. After each change, open the page logged out in a private window with the console open and use it: open the mobile menu, submit a form, run a search, add a product to the cart, accept the cookie banner. Any new error in the console is a script that ran out of order. Check one page per template, then compare the lab figures for Largest Contentful Paint and Total Blocking Time with your baseline.
When render-blocking resources in WordPress need code changes
On a simple site with a well-built theme, an optimization plugin with conservative settings clears most render-blocking warnings, and you can do that yourself with the testing routine above. Results are less predictable on sites with a page builder, a store or many plugins that each bring their own scripts, because the safe settings do little and the aggressive ones break things.
At that point the durable fix is in code: dequeue rules per template, scripts registered with the right strategy and a theme stylesheet that is split sensibly. That is routine work in our performance optimization projects. When the theme or builder is the source of most of the weight, a custom WordPress theme that loads only what each template needs removes the problem instead of hiding it.
Frequently asked questions
Should I use defer or async for WordPress scripts?
Use defer for almost everything. Deferred scripts keep their order, so a library and the code that uses it still work together. Async is for scripts that depend on nothing and that nothing depends on, such as an analytics tag.
Is it safe to defer jQuery?
Only if no inline script on the site calls it before the page has finished parsing, which is rare on sites with page builders or older plugins. Test every template with the console open. If "jQuery is not defined" appears, leave jQuery as it was and defer the scripts that depend on it instead.
Does moving scripts to the footer fix render blocking?
It stops them from blocking the content above them, so the first paint is no longer held up. They still download and run before the page is fully interactive. Deferring gives the same benefit and lets the browser start the download earlier.
Why does PageSpeed Insights still report render-blocking resources?
Some blocking is expected, because a page needs at least its main stylesheet before it can be drawn. Look at the time attributed to each file. If the remaining ones are small and necessary, the warning can be ignored.
Add worldwincoder.com as a preferred source on Google, or open this article in your AI assistant to use it as a source.
