Skip to content
Tutorials Center
My learning

Topics

Lesson 24 of 36 ยท Technical SEO

JavaScript SEO and Mobile-First Indexing

Learn how search engines crawl, render and index JavaScript sites, when to use server-side rendering, and what mobile-first indexing and HTTPS require of you.

Modern sites often build their pages in the browser with JavaScript. Search engines can run JavaScript, but doing so costs extra work and adds a delay and more places to go wrong. Two other technical foundations also deserve attention: the mobile version of your site, which is what most engines index, and HTTPS.

How JavaScript pages are processed

Google processes pages in three broad phases: crawl (fetch the HTML), render (run JavaScript in a headless browser, usually queued after crawling) and index (store the resulting content). Other search engines vary in how well they render JavaScript, and AI and social crawlers often do not run it at all.

flowchart LR
  A["Fetch URL"] --> B["Raw HTML parsed: links, meta, content"]
  B --> C["Render queue"]
  C --> D["JavaScript executed"]
  D --> E["Rendered HTML indexed"]

Anything that is only visible after rendering is processed later and less reliably than what is in the initial HTML.

Rendering strategies

Strategy What arrives in the first response SEO view
Server-side rendering (SSR) Full HTML per request Very good
Static generation (SSG) Prebuilt full HTML Excellent and fast
Hydration Full HTML, then JavaScript makes it interactive Good
Client-side rendering (CSR) Near-empty shell plus script Works, but riskier and slower to index
Dynamic rendering Bots get prerendered HTML A workaround, not recommended long-term

For content that should rank, prefer SSR or static generation so the important text, links, title and canonical are present in the initial HTML.

JavaScript SEO checklist

  • Links must be real: use <a href="/page">. A <div onclick> or a link whose href is # or javascript: will not be followed.
  • Use real URLs. Prefer the History API paths (/products/shoes) over hash fragments (#/products/shoes), which crawlers do not treat as separate pages.
  • Put titles, meta descriptions, canonicals and robots directives in the initial HTML or set them reliably before render finishes. Do not change a noindex with JavaScript: if the raw HTML says noindex, the page may never be rendered.
  • Return correct status codes. A single-page app that answers 200 for every missing route creates soft 404s; return a real 404 from the server.
  • Do not block JavaScript and CSS files in robots.txt (see robots.txt and XML Sitemaps).
  • Lazy-load carefully. Content that loads only on a scroll event or click may never appear to a crawler. Use IntersectionObserver and loading="lazy" for images instead of requiring user input.
  • Test the rendered result with the URL Inspection tool in Search Console, which shows the rendered HTML and screenshot.
Crawlable link or not?

Seeing what a crawler sees

The raw HTML is what a crawler gets before rendering. If your key content is missing from it, you depend on rendering. This script checks a raw response for the essentials.

Python Audit the initial HTML

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Mobile-first indexing

Search engines now primarily use the mobile version of a page for indexing and ranking. If your mobile page has less content than the desktop one, only the smaller version counts.

  • Use responsive design: one URL and one HTML for all devices, with CSS adapting the layout. It is the simplest and the recommended option.
  • Keep the same content, headings, structured data, meta tags and links on mobile as on desktop.
  • Include <meta name="viewport" content="width=device-width, initial-scale=1">.
  • Make tap targets large enough and text readable without zooming.
  • Do not hide important content in a way that makes it unavailable on mobile. Content in tabs or accordions is fine as long as it is in the HTML.
  • Check images and videos load and have alt text and indexable URLs on mobile too.

HTTPS

HTTPS is a lightweight ranking signal, but more importantly browsers warn users about insecure pages and forms. Serve every page over HTTPS, redirect all HTTP URLs with a 301, use a valid certificate, avoid mixed content (HTTP resources inside HTTPS pages) and update canonicals and sitemaps. Consider enabling HSTS once everything works.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which rendering approach puts full content in the initial HTML?

    SSR and static generation deliver complete HTML, so crawlers do not depend on running JavaScript.
  2. 2. Which link will crawlers reliably follow?

    An anchor with a real href is discovered as a URL; the other forms hide it from crawlers.
  3. 3. What does mobile-first indexing mean?

    Engines primarily use the mobile rendition, so it should contain the same essential content as desktop.
  4. 4. A single-page app returns status 200 for a missing page. What is this called?

    A not-found message served with a 200 status is a soft 404; the server should send a real 404.

Summary

  • Rendering JavaScript costs search engines time; critical content belongs in the initial HTML.
  • Use SSR or static generation for pages that need to rank.
  • Use real anchor links, real URLs, proper status codes and unblocked resources.
  • Keep mobile and desktop content equivalent; design responsively.
  • Serve everything over HTTPS with clean redirects.

Next: Content Strategy and Topical Authority