Does your site’s JavaScript actually work?
PerformanceA WordPress site quickly runs a dozen JavaScript libraries: one for the slider, one for the lightbox, one for the scroll animations, one for the form.
5 min read
By Timo Wessels Published
A WordPress page quickly ends up running a dozen JavaScript libraries: one for the slider, one for the lightbox window, one for the animations on scroll, one for the form. Each comes from a different plugin, and none knows about the others.
The important question is not whether they are loaded. It is: do they really work? Loaded does not mean working.
The most important points first:
- A script can be loaded and still do nothing. You only notice by clicking through the page.
- AI search systems do not run JavaScript. Text that only appears after a click does not exist for them.
- The number of elements on a page says little on its own about its speed.
Why it matters
Mistakes nobody notices
Some mistakes are broken without anyone noticing:
- A script starts before the library it depends on is there. Then it runs into nothing.
- A
.jsaddress delivers an HTML error page instead of the file. The browser accepts that silently. - A slider is fully prepared in the HTML, but the library that moves it was never started. Then all slides stand one below the other, or are not there at all.
You rarely notice this yourself. You usually look at the page in one place only, and your own browser has the files in its cache.
AI systems do not see JavaScript
Vercel studied how the crawlers of AI services read websites. Result: none of the major AI crawlers currently runs JavaScript. That covers OpenAI (OAI-SearchBot, ChatGPT-User, GPTBot), Anthropic (ClaudeBot), Meta, ByteDance and Perplexity. Google does run JavaScript, but with a delay: Googlebot first puts pages in a queue for rendering, and that can take longer than a few seconds. Google also points out that not all bots can run JavaScript and that pages the server delivers ready-made are faster for users and bots.
For you this means: text that is only loaded after a click on a tab does not exist for these systems.
Page complexity
This is the quieter question: how many elements is the page made of, and how deeply are they nested?
I am deliberately cautious here, because too much is often read into it:
- Chrome writes in the Lighthouse documentation that a very large element tree can slow a page in several ways: loading, rendering and memory. Lighthouse warns above about 800 elements in the body of the page.
- A number alone does not say how fast your page is. There is no general number for “too many” or “too deep”. The thresholds are Google’s warning points, so hints and not rules.
- In a rebuild, element count and load time often fall together. That does not mean one causes the other. Both come from the same clean-up.
You only see the value of such numbers the second time. One measurement gives three boring numbers. Two measurements, before and after a rebuild, give a before and after that a client without technical terms understands too.
A caveat when judging
An optimisation plugin that holds scripts back until the first interaction looks, on a plain page load, exactly like a broken script. That is a case for a human, not for a verdict.
How to check it yourself
Read the console: Open your page in a private window, then the developer tools with F12 and the “Console” tab. Reload.
Red lines are errors. The most common messages in my experience:
... is not defined: A script used something that was not there yet.Uncaught SyntaxErroron a.jsfile: The file is often not a JavaScript file at all but an error page.404on a.jsaddress: The file is missing.
Not every red line is yours. Browser extensions and antivirus programs also write to the console. If in doubt, check in a browser without extensions.
Click through the page: Click through everything once: slider, foldable sections, tabs, the image window, the menu on a phone and the form. That takes five minutes and finds more than any tool.
Check visibility: Switch JavaScript off in the browser and reload. What is still there is what search engines and AI systems reliably get.
Find unused code: The Coverage panel of Chrome’s developer tools shows how much JavaScript and CSS the page loads but does not use. Chrome notes that finding it is easy, but cleaning it up can be hard.
What you can do if it is missing
1. For every console error, find the plugin. The file path in the message usually tells you. The cause is often mundane: a plugin nobody maintains any more, or two plugins that bring the same library in different versions.
2. With an optimisation plugin, switch off the combining and delaying of JavaScript as a test. A large share of script errors on WordPress pages only arises there, because combining files tips their order.
3. The main text belongs in the delivered HTML. If content sits in tabs or foldable sections, it should be in the HTML and only visually folded. It must not be loaded in by script.
4. Build with less nesting. The way is not through a target number but through the build. Page builders create extra containers for every row and column. A build with modern CSS layout needs a fraction of them. That is a question of how you build, not an optimisation step afterwards.
5. Do not load libraries you do not need, and write clean HTML.
Sources
- Google Search Central, JavaScript SEO basics — pages go into a queue for rendering, which can take longer than a few seconds; not all bots can run JavaScript: developers.google.com(external site: developers.google.com)
- Vercel, The rise of the AI crawler — none of the major AI crawlers currently runs JavaScript: vercel.com(external site: vercel.com)
- Chrome for Developers, Avoid an excessive DOM size — a large element tree can slow loading, rendering and memory, warning above about 800 elements in the body: developer.chrome.com(external site: developer.chrome.com)
- Chrome for Developers, Coverage: Find unused JavaScript and CSS — finding unused JavaScript and CSS: developer.chrome.com(external site: developer.chrome.com)
- Own testing practice — the error patterns in the console, loaded is not working, filtering out messages from browser extensions, the caveat on the optimisation plugin, element count as a complexity measure, the value of a before-and-after comparison, page-builder nesting.