DEV Community

Cover image for Common SEO Mistakes Developers Make in JavaScript Websites
Vibes
Vibes

Posted on

Common SEO Mistakes Developers Make in JavaScript Websites

Most JavaScript websites I audit are not broken because the developer did something wrong on purpose. They are broken because the page Google sees and the page the user sees are two different pages.

A founder builds a site with an AI tool like Lovable, Bolt, or v0, and gets a working product in a weekend. What they usually get is a Vite React single-page app, and Google sees almost none of it. The site looks finished in the browser and is nearly empty to a crawler.

This post covers the ten mistakes I see most often in JavaScript websites, the fix for each one, one trap nobody warns you about, and a five-minute test that shows you exactly what Google sees.

How Google Actually Handles JavaScript

Google handles JavaScript in three phases: crawl, render, then index. It indexes the rendered HTML, not the raw source you see when you click view source.

That middle phase is where the trouble starts. A page can sit in the render queue for a few seconds, but it can take longer than that, in Google's own words. Vercel and MERJ measured Googlebot on a large site in 2024 and found a median wait of 10 seconds from crawl to finished render, and the slowest 1 percent waited about 18 hours.

Google's own JavaScript SEO basics guide says server-side or pre-rendering is still a great idea, because it makes the site faster for users and crawlers, and not all bots can run JavaScript. As Martin Splitt from Google put it, a lot of people are still looking at view source, and that is not what Google uses for indexing. Google uses the rendered HTML.

Mistake 1: Content That Only Exists After JavaScript Runs

The most common mistake is also the most basic: the server sends an almost empty shell, a div with an id, and everything else only exists after JavaScript runs. All seven guides I read for this post cover it, and it is still the one I find most often.

The classic version is an H1 set inside a useEffect after an API fetch. The user sees a headline, the crawler sees an empty div, and the content only appears in Google's delayed second pass, late, partially, or never. Other crawlers and AI bots often cannot render JavaScript at all, so for them the page stays empty.

The fix is simple to say and harder to ship: use server-side rendering or static generation for every public page you want to rank, and keep client-side rendering for logged-in areas. In Next.js that means Server Components, getStaticProps, or getServerSideProps. In Nuxt it means SSR, in Angular it means Angular Universal, and for an existing SPA it means prerendering with a tool like Prerender.io.

Mistake 2: Empty or Duplicate Meta Tags

Every route ships the same title, usually React App, with no meta description and no Open Graph tags. Six of the seven guides I read cover this one, and every shared link ends up showing the same preview.

Tags set by React Helmet after the page mounts exist only in the rendered DOM. Google usually picks them up in its delayed second pass, but AI crawlers and link previews on Slack, LinkedIn, and iMessage never run JavaScript, so they see nothing.

Give every route a unique title under 60 characters and a description around 150 characters, rendered in the initial HTML. In Next.js use the metadata export or generateMetadata, in React use react-helmet-async, in Vue use @unhead/vue, and in Angular use the Title and Meta services.

Mistake 3: Links That Are Not Links

A div with an onClick that calls router.push is not a link, and Googlebot will never follow it. This is the mistake that silently deletes a whole site's internal linking.

Google can only discover links that are a elements with an href attribute. When navigation lives in click handlers, the internal link graph disappears, and pages that are not linked from anywhere are never discovered at all.

Use real anchors everywhere: the Link component in Next.js, Link in React Router, router-link in Vue Router, or a plain a href. If it navigates, it should be an anchor, not a div.

Mistake 4: Canonical and Hreflang Injected After Load

A canonical tag added by JavaScript after hydration is often missed by Google, and the wrong language page can end up ranking in the wrong market.

There is a second version of this trap that only Sitebulb covers: when the canonical in the response HTML and the canonical in the rendered HTML are different, search engines may honour the wrong one. Google's own rule is to never use JavaScript to change the canonical to a different value than the one in the original HTML.

Render the canonical and hreflang server-side, in the initial HTML. In Next.js, generateMetadata handles alternates.canonical and alternates.languages, and every page should carry a self-referencing absolute canonical.

Mistake 5: Lazy Loading the Content Google Needs First

Lazy loading is meant for content below the fold, but I keep seeing it on the hero image and the main copy. That is the content Google needs first, and it is the content that gets delayed.

A lazy-loaded hero image delays the Largest Contentful Paint, and images without width and height cause layout shift. Text that loads only when the user scrolls may never be indexed at all, because Googlebot does not click and does not scroll.

Lazy-load only below-the-fold images and non-critical resources, and always with explicit dimensions. The hero image should load eagerly with fetchpriority set to high. Content inside tabs and accordions should be in the DOM at load and hidden with CSS if you need it hidden.

Mistake 6: No Structured Data

No JSON-LD means no rich results, and AI tools like ChatGPT understand the page less well. Four of the guides I read cover this, and it is still missing from most JavaScript sites I audit.

Add JSON-LD in the HTML for the types that fit the page: Article, Product, SoftwareApplication, FAQPage, and BreadcrumbList are the common ones. Google confirms that JavaScript-generated JSON-LD is acceptable, as long as you test it, so validate the result with the Google Rich Results Test.

Structured data will not fix a page Google cannot render, but once the page renders, it is the cheapest way to win more space in the results.

Mistake 7: Soft 404s on Dynamic Routes

The single-page app server returns index.html with a 200 status for every path, so a page that does not exist looks like a real page to Google. The app shows a Not found message, and Google indexes the junk URL.

Hit a dynamic route with an invalid ID and the page renders an Oops, not found message at HTTP 200. Google logs soft 404s, and if the pattern repeats it can drop the whole URL pattern. Martin Splitt described it plainly: instead of responding with 404, the site just responds with 200, always showing a page based on the JavaScript execution.

Return a real 404 from the server or framework: return notFound true in Next.js, or res.status(404) in Express. Google's own workarounds for JavaScript-only sites are a redirect to a server 404 URL, or injecting a noindex meta tag with JavaScript on error pages.

Mistake 8: A Missing or Stale Sitemap

A JavaScript site with no sitemap leaves discovery to chance, and a stale sitemap wastes crawl budget. Pages that are not linked from the homepage may never be found at all.

On a large single-page app the sitemap has to list only canonical, indexable URLs. Error URLs, redirected URLs, and noindex URLs in the sitemap are wasted fetches, and they send Google the wrong signal about what matters on the site.

Generate the sitemap at build time from the real routes, include lastmod, refresh it on every deploy, and submit it in Google Search Console and Bing Webmaster Tools.

Mistake 9: Infinite Scroll With No Pagination

Content that only loads when the user scrolls is content Google never sees. Search engines cannot access it, and Google's guidance says to follow its pagination guidelines and avoid infinite scroll.

The fix is pagination with crawlable links: a href links to page 2, page 3, and so on. If you want the scroll experience, add a Load More button that also exposes those paginated URLs, so users get the smooth feed and crawlers get the links.

Mistake 10: Blocking JavaScript in robots.txt or Leaving noindex Live

Two lines in the wrong file can remove a whole site from Google: a staging Disallow pushed to production, or a noindex tag that survives launch.

A Disallow for JavaScript or CSS files stops Googlebot rendering the page at all, because it will not render JavaScript from blocked files. A noindex tag from staging does the same thing in reverse: the page never indexes. Gate staging with an environment variable, so production always gets index, follow, and check robots.txt after every deploy.

There is also the inverted version of this trap, which only Sitebulb covers. If noindex is in the response HTML but JavaScript removes it, Google skips rendering entirely, so it never sees that the noindex was removed, and the page is never indexed. Fix noindex in the HTML, never in JavaScript.

The Mistake Nobody Warns You About: Hydration Mismatch Turns SSR Back Into CSR

Here is the mistake none of the guides I read warns you about: your server-side rendering can silently turn back into client-side rendering, and you will never see it happen.

When the HTML the server sends and the HTML the client renders disagree, React throws a hydration error and discards the server HTML, re-rendering everything on the client. The page you thought was server-rendered is, in practice, client-rendered again, with all the same SEO risks: delayed indexing, and missing content if the re-render fails.

The usual causes are small and easy to miss: a date rendered differently on the server and the client, a random ID or Math.random in the markup, a browser-only API like window or localStorage read during render, and HTML that changes after an auth check.

You can spot it three ways: hydration warnings in the browser console, content that flashes or disappears on load, and rendered HTML in Search Console that is missing content present in the raw HTML. Prevent it by rendering browser-only parts after mount, keeping server and client data identical, and using suppressHydrationWarning only where the difference is expected.

One more silent delay works the same way. Google's rendering service may cache your JavaScript and CSS for up to 30 days, ignoring your own caching headers, so a fix you shipped can take weeks to show up in Google's render. The fix is content fingerprinting, a filename like main.2bb85551.js that changes with every build.

Ranking on Google and Invisible to AI Search at the Same Time

Your site can rank on Google and be invisible to AI search at the same time, and this is the part most developers have not heard yet.

Vercel and MERJ tested the major AI crawlers in December 2024 and found that none of them rendered JavaScript. GPTBot, ClaudeBot, and PerplexityBot fetched the raw HTML and moved on. A client-side rendered site gets no citations in ChatGPT, Claude, or Perplexity, because there is nothing in the raw HTML to cite.

The fix is the same as mistake one: server-rendered HTML. Bing renders JavaScript with limits, and its index feeds Copilot, so a page that cannot be reliably rendered may not be indexed or selected for grounding there either.

Quick Comparison

The table below compares the ten mistakes side by side: what breaks, and the fix.

Mistake What Breaks The Fix
CSR-only content Google indexes late, partially, or never SSR or SSG for public pages
Empty or duplicate meta tags No per-page signal, same preview everywhere Unique title and description in initial HTML
Links that are not links Pages never discovered, link graph gone Real a href anchors everywhere
Canonical and hreflang after load Wrong page or language ranked Render canonical and hreflang server-side
Lazy loading critical content Hero and copy missed, LCP and CLS suffer Lazy-load below the fold only, with dimensions
No structured data No rich results, weaker AI understanding JSON-LD in HTML, validate with Rich Results Test
Soft 404s Junk URLs indexed, trust drops Real 404 from the server
Missing or stale sitemap Pages never discovered, crawl budget wasted Build-time sitemap, only indexable URLs
Infinite scroll, no pagination Content past the fold never indexed Crawlable paginated links
Blocked JS or live noindex Rendering blocked or page never indexed Allow JS and CSS, gate noindex by environment
Hydration mismatch SSR silently becomes CSR again Identical server and client render

The 5-Minute Test: See What Google Actually Sees

You do not need a paid tool to see what Google sees. Five minutes is enough.

First, disable JavaScript in Chrome DevTools and reload the page. If the page is blank, that is Googlebot's first view of it. Second, curl the page and grep for your headline: if the headline is not in the response, neither is it in Google's first pass. Third, curl the page with the GPTBot user agent to see what AI crawlers get.

curl https://example.com | grep -i "your headline"
Enter fullscreen mode Exit fullscreen mode
curl -A "GPTBot/1.0" https://example.com | grep -i "your headline"
Enter fullscreen mode Exit fullscreen mode

Fourth, compare the raw HTML with the rendered HTML using Screaming Frog in JavaScript rendering mode or the View Rendered Source extension. Fifth, run the URL through Search Console URL Inspection, click Test Live URL, then View tested page: the HTML tab shows what Google indexed, and the Screenshot tab shows the render.

FAQs

Three questions developers ask me most often about JavaScript and SEO.

Can Google index a JavaScript website?

Yes, Google can index JavaScript websites, but only after rendering, and rendering is delayed. Google uses an evergreen Chromium renderer, and content can be indexed late or partially.

Other crawlers often cannot render JavaScript at all, so server-rendered HTML is the safe route for any page you want found, ranked, or cited.

Is client-side rendering bad for SEO?

Client-side rendering is not bad for logged-in pages, but it is a bad default for public pages you want to rank. Behind a login, nobody needs to find the page in search, so render it however you like.

For public pages, use server-side rendering or static generation, and use prerendering as the bridge for an existing single-page app.

Do I need to rebuild my SPA in Next.js to rank?

No, you do not need to rebuild to rank, but you do need server-rendered HTML somehow. Prerendering an existing SPA takes an afternoon, with a service like Prerender.io or Rendertron, and it is the practical first step.

Server-side rendering or static generation is the better choice for the next rebuild. Dynamic rendering is a workaround, not a long-term fix, and it is not cloaking as long as the served content matches what users see.


About the Author

Written by Belayet Hossen Sakib. He is a professional SEO expert. He provides SEO consultancy and search engine optimization services with strategic leadership for SEO client projects, from technical audits and keyword research to content that gets cited on Google and AI platforms like ChatGPT, Gemini, and Perplexity.

Top comments (0)