Skip to content

Delay JavaScript execution and SEO: scripts Googlebot never runs

Delay JavaScript execution holds scripts until a visitor interacts, and Googlebot never interacts. How to find content, schema and widgets crawlers no longer see.

By Crawlito · 9 min read

In short

  • WP Rocket's Delay JavaScript execution rewrites scripts to type="text/rocketlazyloadscript" and runs them only after events such as mousemove, touchstart, keydown, wheel or click.
  • Google says Google Search does not interact with your page, so anything a delayed script would inject, such as JSON-LD, reviews or menu links, is missing when Googlebot renders the page.
  • LiteSpeed Cache has two modes: Deferred runs scripts once the HTML has loaded, while Delayed runs them only after user activity; only Delayed carries the interaction risk.
  • Cloudflare Rocket Loader defers JavaScript until after rendering rather than waiting for a visitor, and a script opts out with data-cfasync="false" placed before src.
  • Test logged out, compare the served HTML with the page URL Inspection's live test shows, and add any script that outputs content or structured data to the plugin's exclusion list.
On this page

Delay JavaScript execution is safe for SEO only for scripts that output nothing a crawler needs. The setting in WP Rocket, and the Delayed mode in LiteSpeed Cache, hold scripts until a visitor moves the mouse, touches the screen, scrolls or presses a key. Google says Google Search does not interact with your page, so a delayed script never runs for Googlebot. If that script injects structured data, review stars, menu links or product details, Google renders the page without them, and AI crawlers that read only the raw HTML never had them in the first place.

The fix is not to switch the feature off. It is to find the few scripts that produce content and exclude them, while analytics, chat widgets and ad tags stay delayed.

What Delay JavaScript execution actually does

WP Rocket's Delay JavaScript execution documentation describes the mechanism precisely. On cached and optimized pages, it changes every eligible script so the browser does not run it:

html
<!-- What your theme or plugin printed -->
<script src="/wp-content/plugins/reviews/widget.js"></script>

<!-- What WP Rocket serves with Delay JavaScript execution on -->
<script type="text/rocketlazyloadscript"
        data-rocket-src="/wp-content/plugins/reviews/widget.js"></script>

A type the browser does not recognise means the script is not executed, and moving src to data-rocket-src stops it loading. Any original type is kept in data-rocket-type. WP Rocket's own loader restores the scripts only when one of a list of user events fires. The documented list includes keydown, mousedown, mousemove, mouseover, touchstart, touchmove, wheel, click, input and onscroll, among others. The page does not describe a time-based fallback.

WP Rocket also notes two limits worth knowing: scripts added after the page loads, or fetched by another script, cannot be delayed, and Combine JavaScript files is turned off while delay is on.

LiteSpeed Cache offers the same idea under Load JS Deferred, which has three values in its page optimization documentation:

LiteSpeed settingWhen scripts runCrawler risk
OffNormallyNone from this setting
Deferred"As soon as the HTML finishes loading"Low: scripts still run without a visitor
DelayedOnly after user activity, "such as a key press or mouse movement"High for any script that outputs content

LiteSpeed is open about why people choose Delayed: it says the mode "can remove JS entirely from the page speed score calculation". That is also the reason it can remove the output of those scripts from what a crawler sees.

Why Googlebot never triggers delayed scripts

Googlebot does run JavaScript. Google's JavaScript SEO basics explain that pages are queued for rendering and that "a headless Chromium renders the page and executes the JavaScript", after which Google uses the rendered HTML for indexing.

Rendering is not the same as using the page. Google's lazy-loading guidance says it directly: "Google Search does not interact with your page." Its recommended methods are the ones that do not rely on user actions such as scrolling or clicking. A script that waits for mousemove or touchstart is, by design, a script that relies on user action, so in Google's renderer it stays as inert text/rocketlazyloadscript.

For AI crawlers the situation is usually worse, not better. Most AI crawler operators do not document JavaScript rendering, and independent tests have found several of them read only the raw HTML, as covered in Do AI crawlers run JavaScript?. For those crawlers, delay changes nothing: content that depends on any script was already missing. The new loss is Google, which would have rendered that content before you turned the setting on.

What the script doesWithout delayWith Delay JavaScript execution
Analytics, pixels, heatmapsRuns for visitors and Google's rendererRuns on interaction; nothing a crawler needs is lost
Live chat, cookie banners, ad tagsRuns for visitors and Google's rendererRuns on interaction; usually fine
JSON-LD injected by a script or tag managerGoogle sees it after renderingGoogle does not see it
Review widget that prints stars and review textGoogle sees the text after renderingGoogle does not see it
Menu or mega-menu built in JavaScriptGoogle discovers the links after renderingLinks are missing from the rendered HTML
"Load more", sliders, tabs filled by a scriptGoogle sees the first statePossibly empty panels or placeholders

Which WordPress content is at risk

Content that your theme or SEO plugin prints into the HTML on the server is not affected. Delay changes scripts, not the text, headings and links PHP already wrote into the page. The risk sits with anything that a script builds in the browser.

Structured data added by JavaScript

Google supports structured data that is "available in the DOM when it renders the page", according to its guide to generating structured data with JavaScript. Markup added through a Google Tag Manager Custom HTML tag, or by a reviews or FAQ plugin that builds its JSON-LD in the browser, only reaches the DOM if its script runs. If the GTM container script is delayed, so is every tag inside it. Schema markup through Google Tag Manager covers that setup in more detail.

A JSON-LD block printed in the page source is data, not code the browser executes, so it should not need a visitor. WP Rocket does not document how it treats application/ld+json blocks, though, so check rather than assume. In the served HTML, every structured data block should still read:

html
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"Product","name":"Trail boot"}
</script>

If a block shows type="text/rocketlazyloadscript" or a data-rocket-type="application/ld+json" attribute instead, the markup has been rewritten and is no longer a JSON-LD block, so do not count on Google reading it as structured data. JSON-LD errors lists the other ways a block can silently fail.

Widgets, menus and content panels

WP Rocket's compatibility exclusions page warns that with delay enabled, elements such as "a menu, or a form" may take time or user interaction to appear. For visitors that is a brief flash. For a crawler that never interacts, it is permanent. Review carousels, store locators, pricing tables filled from an API and tab panels populated by a script all fall in this group. The same "hidden is fine, fetched is not" logic from lazy loaded tabs and accordions applies, with one difference: here even content that loads on its own is held back, because the script that would load it is waiting.

How Rocket Loader and "defer" differ

Not every JavaScript optimization waits for a visitor. The distinction that matters is whether scripts run on their own after the page loads, or only after an interaction.

FeatureWhen scripts runOpt-out per script
WP Rocket: Delay JavaScript executionOn user interactionExclusion list, one-click exclusions, nowprocket keyword or data-nowprocket
LiteSpeed Cache: DeferredWhen the HTML has finished loadingJS Deferred/Delayed Excludes
LiteSpeed Cache: DelayedAfter user activityJS Deferred/Delayed Excludes
Cloudflare Rocket LoaderAfter rendering, keeping execution orderdata-cfasync="false" before src

Cloudflare's Rocket Loader documentation describes it as "deferring the loading of all of your JavaScript until after rendering". Cloudflare describes no wait for user interaction, so scripts should still run in a renderer that does not interact. It can still break scripts that expect to run early, and Cloudflare's advice is to disable it and retest if you see JavaScript or jQuery issues. To keep a single script out of it, Cloudflare's ignore JavaScripts page says the attribute must come before src:

html
<script data-cfasync="false" src="/js/schema-builder.js"></script>

Deferring is not risk-free for AI crawlers that run no JavaScript, because they never saw script output to begin with. But for Googlebot, deferred scripts behave like normal scripts that simply start later. Delayed scripts do not start at all.

How to find what delay removed

Test as a logged-out visitor. LiteSpeed's Optimize for Guest Only setting is on by default and applies CSS and JavaScript optimizations only to visitors who are not logged in, and WP Rocket's delay applies only to cached or optimized pages. An admin checking the site while logged in may never see the problem.

  1. Look at the served HTML. Open the page in a private window, view the source and search for rocketlazyloadscript (WP Rocket) or check which scripts carry a changed type. Each match is a script that will not run without a visitor. Note the file names.
  2. Compare with optimizations bypassed. WP Rocket's troubleshooting article suggests adding ?nowprocket to the URL to load the page without its optimizations. Anything visible there and missing in step 3 is caused by delay.
  3. Render the page without touching it. In Search Console, run URL Inspection, choose Test live URL, then View tested page, and search the HTML it shows for a review sentence, a menu link and your "@type" values. For structured data, Google's guide recommends the Rich Results Test with the URL input, which also renders the page.
  4. Watch what interaction adds. In Chrome DevTools, open the Elements panel, load the page and keep the mouse still. Then move it once. Whatever appears in the DOM at that moment came from a delayed script.
  5. Check the raw HTML separately. Fetch the page with curl and confirm your main text and JSON-LD are in the response, since that is all a non-rendering AI crawler gets:
bash
curl -s https://example.com/product/trail-boot/ \
  | grep -o '<script[^>]*ld+json[^>]*>'

A result of <script type="application/ld+json"> is what you want. A tag that also carries rocketlazyloadscript has been rewritten, and no output means the markup is not in the raw HTML at all.

How to exclude the scripts that output content

Once you know which scripts build content, exclude only those. In WP Rocket's Delay JavaScript execution settings, use either the One-click exclusions checkboxes for listed plugins and themes, or the Excluded JavaScript Files box. The troubleshooting article explains that exclusions match keywords, not only full paths, so a folder or file name is enough:

/wp-content/plugins/site-reviews/
/wp-content/plugins/mega-menu/js/(.*).js
googletagmanager.com/gtm.js
reviewWidgetInit

The last line is a string from inside an inline script: WP Rocket says to choose a string of text that is unique to that script, so the exclusion does not catch others. You can also exclude a script at the source by adding data-nowprocket to its tag or a // nowprocket comment inside it. Treat Safe Mode as a stopgap: it excludes scripts under /wp-content/ and /wp-includes/, jQuery and inline scripts added with wp_add_inline_script(), and WP Rocket calls it "a last resource" to use only while you find the files that need excluding.

In LiteSpeed Cache, add the file URLs or partial strings to JS Deferred/Delayed Excludes, one per line and without wildcards, as LiteSpeed's docs specify, or switch Load JS Deferred from Delayed to Deferred if too many scripts need excluding. Then repeat the test from the previous section. Page speed trade-offs are covered separately in Core Web Vitals and AI search: no crawler documentation rewards a delayed analytics tag, and a crawler can only use content that is in the page it receives.

The most robust fix is to stop depending on scripts for content at all: output JSON-LD from your SEO plugin on the server, render menus as normal <a href> links in the theme, and print review text server-side. The WordPress AI search readiness guide covers the plugin settings that make this easier.

Frequently asked questions

Does Delay JavaScript execution hurt SEO?

Not by itself. It only removes what delayed scripts would have added, so it is harmless for analytics and chat widgets and harmful for scripts that inject structured data, links or visible content. Test each template and exclude the scripts that build content.

Does Googlebot move the mouse or scroll to trigger delayed scripts?

Google says Google Search does not interact with your page, and it recommends lazy-loading methods that do not rely on scrolling or clicking. Plan on delayed scripts never running when Google renders the page.

Is my Yoast or Rank Math schema affected?

Schema that the plugin prints into the HTML on the server is not built by a script, so it should still be present. WP Rocket does not document its handling of application/ld+json blocks, so view the source logged out and confirm each block still has that type.

Is LiteSpeed's Deferred mode safe for crawlers?

Deferred runs scripts once the HTML has finished loading, without waiting for a visitor, so Google's renderer still runs them. Delayed is the mode that waits for user activity and needs exclusions.

Should I use Rocket Loader instead?

Rocket Loader defers scripts until after rendering rather than waiting for interaction, so it avoids this specific problem. It has its own compatibility issues, and neither approach helps AI crawlers that run no JavaScript.

Check a page after changing the setting

After enabling delay or adding exclusions, run the free check on a product page or article to see the HTML a crawler receives, with no account needed. If the setting applies across many templates, an audit covers up to 500 pages, with human review and a PDF of evidence and prioritized fixes.

Filed under Rendering and content. Topics: wordpress, javascript, rendering, googlebot, structured-data