Reducing JavaScript on WordPress for better INP
The page loads fast. Then you tap the menu and it just sits there. Tap a filter, same thing.
Those interactions usually depend on JavaScript, and too much work on the main thread delays the browser’s response. With INP replacing FID as a Core Web Vital on 12 March 2024, it’s worth looking beyond the first load and testing what visitors actually do.
Cutting JavaScript doesn’t mean disabling every plugin. First find the slow interaction and the scripts running around it. Then remove duplicates, limit scripts to the pages that need them, and test each change on staging before it goes near the live site.
Start with a real interaction
Choose a page that matters: a product page, menu, search results page or form. Identify the exact action that feels delayed and reproduce it on a phone as well as a desktop. Note whether the delay occurs before any visual feedback, while the browser is processing the page, or while the server responds.
Use field data where available. Search Console’s Core Web Vitals report and PageSpeed Insights can help identify affected URLs or patterns. A browser performance trace can show long tasks that block input. A lab score won’t tell you which feature is frustrating visitors, so test the interaction itself.
If the slow page is part of a shared template, compare it with another page using that template. If the issue appears only on one URL, look for page-specific blocks, embeds or scripts. A quick comparison stops you removing a site-wide feature to fix a local problem.
Inventory the scripts
WordPress themes, plugins, page builders, analytics, advertising tags and external widgets may all add JavaScript. I start by listing everything that loads on the affected page. Browser developer tools show script requests and timing. A performance plugin or asset manager gives an overview too, but I verify what it recommends.
For each script, ask what it does, who relies on it and where it must run. A review widget may be important on product pages but unnecessary on the homepage. A form script should load where forms appear. Analytics may be required across the site, but a duplicate tracking tag can usually be removed after checking with the person responsible for measurement.
A plugin’s name appearing in a report doesn’t make it the cause. Plugins share libraries, and one script can be held up by another task. Find the actual work and test changes one at a time.
Reduce work safely
Remove what is genuinely unused
Deactivate and remove plugins that no longer serve a purpose after confirming their data and features are not needed. Check whether another plugin depends on them. Removing a plugin can also remove shortcodes or blocks that appear in content, so inspect affected pages first.
Limit scripts to relevant pages
If an extension loads assets everywhere, look for a setting to load them only where needed. Some plugins support conditional loading; an asset manager may provide controls. Test carefully, because blocking a dependency can make a feature silently fail.
Avoid duplicate features
A theme may already provide a slider, popup or icon set that another plugin adds again. Choose one implementation when possible. Duplicate analytics, chat widgets, animation libraries and page-builder add-ons can add weight and conflict.
Defer non-critical work
Loading a script later frees the browser to respond sooner, but timing changes can break dependencies. Test menus, forms, tracking and consent. I wouldn’t defer a script just because a tool says so.
Keep code lean
If custom code handles an interaction, remove unnecessary event listeners and expensive work that runs repeatedly. Break up long tasks and avoid recalculating the entire page after a small change. If the code is unfamiliar, ask a developer to review it before editing.
Test on staging and keep a rollback
Before changing script loading or plugin setup, take a backup and use staging if available. Record the current configuration. Change one thing, then test the exact interaction, related pages, mobile layout, keyboard access and browser console.
After launch, revisit the field reports after enough data has accumulated. A faster lab trace is useful evidence, but it does not guarantee that every real visit improved. If the interaction breaks or the report worsens, restore the previous setup and investigate the cause.
Keep the site owner informed about trade-offs. A third-party script may support a business process even if it affects performance. The right answer may be to replace or reconfigure it, not to remove it without discussion.
Prioritise what visitors notice
A WordPress site can contain many scripts without every one being harmful. Focus on the work that blocks important interactions. Improving a menu or add-to-cart response may matter more than removing a small script that runs after the page is already usable.
INP is one measure in a wider experience. Make changes because they help people use the site, then check the metrics. And never promise ranking gains from a JavaScript cleanup.
Make script ownership visible
Before removing or changing a script, record which theme or plugin adds it and what feature depends on it. WordPress sites can load similar assets from more than one extension, so the visible filename may not make ownership obvious. Check the plugin settings, theme documentation and page output. If several components depend on the same library, a change intended to remove duplication can break all of them.
For a site maintained by a team, keep a short note about conditional loading rules and the pages where they apply. Revisit the note after a theme or plugin update, because an extension may change how it enqueues assets. This small bit of documentation helps the next person understand why a script was limited to a template and reduces the temptation to switch on every asset globally when a feature stops working.
Related reading
- INP is now a Core Web Vital: what to fix first
- Reading a Lighthouse report without panicking
- WordPress staging sites: how to test changes safely
Open one important page and reproduce a slow interaction. Which script or task is involved? Find out before you disable anything, and try it on staging first.