How to Optimize JS for Search Engines


What Is JavaScript Website positioning?

JavaScript Website positioning is part of technical Website positioning that focuses on making web sites constructed with JavaScript simpler for search engines like google and yahoo to crawl, render, and index. 

Widespread duties embody the next: 

  • Optimizing content material injected by way of JavaScript
  • Accurately implementing lazy loading 
  • Following inside linking finest practices
  • Stopping, discovering, and fixing JavaScript points

And others. 

Word: When you want to refresh your data about primary JS, learn our information: What Is JavaScript & What Do You Use It For?

How Does Google Crawl and Index JavaScript?

Google processes JS in three phases:

  1. Crawling
  2. Rendering
  3. Indexing
Picture Supply: Google

Google’s internet crawler (often called Googlebot) queues pages for crawling and rendering. 

It crawls each URL within the queue. 

Googlebot makes a request. Then the server sends the HTML doc. 

Subsequent, Googlebot decides which assets it wants to render the web page’s content material.

This implies it crawls the HTML. Not JS or CSS information as a result of rendering JavaScript requires immense assets. 

Take into consideration all of the computing energy Googlebot wants to obtain, learn, and run JS for trillions of pages on almost 2 billion websites

So, Google defers rendering JavaScript. It queues something unexecuted to course of later as assets turn into obtainable. 

As soon as assets permit, a headless Chromium (Chrome browser and not using a person interface) renders the web page and executes the JavaScript. 

Googlebot processes the rendered HTML once more for hyperlinks. And queues the URLs it finds for crawling. 

Within the remaining step, Google makes use of the rendered HTML to index the web page.

Server-Aspect Rendering vs. Shopper-Aspect Rendering vs. Dynamic Rendering

Google JavaScript indexing points are largely based mostly on how your web site renders this code: server-side, client-side, or dynamic rendering. 

Server-Aspect Rendering

Server-side rendering (SSR) is when JavaScript is rendered on the server. A rendered HTML web page is then served to the shopper (browser, Googlebot, and so on.). 

For instance, once you go to a web site, your browser makes a request to the server that holds the web site’s content material. 

As soon as the request is processed, your browser returns the rendered HTML and exhibits it in your display screen. 

SSR tends to assist pages with Website positioning efficiency as a result of: 

  • It could possibly cut back the time it takes for a web page’s foremost content material to load 
  • It could possibly cut back structure shifts that hurt the person expertise

However, SSR can enhance the period of time it takes for your web page to permit person inputs. 

Which is why some web sites that deal closely in JS choose to use SSR for some pages and never others. 

Underneath hybrid fashions like that, SSR is normally reserved for pages that matter for Website positioning functions. And client-side rendering (CSR) is normally reserved for pages that require a whole lot of person interplay and inputs.

However implementing SSR is usually complicated and difficult for builders. 

Nonetheless, there are instruments to assist implement SSR: 

  • Gatsby and Subsequent.JS for the React framework
  • Angular Common for the Angular framework
  • Nuxt.js for the Vue.js framework

Learn this guide to study extra about organising server-side rendering. 

Shopper-Aspect Rendering

CSR is the alternative of SSR. On this case, JavaScript is rendered on the shopper facet (browser or Googlebot, on this case) utilizing the Doc Object Mannequin (DOM). 

Relatively than receiving the content material from the HTML doc as in server-side rendering, you get a bare-bones HTML with a JavaScript file that renders the remainder of the positioning utilizing the browser. 

Most web sites that use CSR have complicated person interfaces or many interactions. 

Try this guide to study extra about how to arrange client-side rendering. 

Dynamic Rendering

Dynamic Rendering is an alternate to server-side rendering. 

how dynamic rendering works infographic

It detects bots which will have issues with JS-generated content material and delivers a server-rendered model with out JavaScript. 

All whereas exhibiting customers the client-side rendered model. 

Dynamic rendering is a workaround and never an answer Google recommends. It creates extra, pointless complexities and assets for Google. 

You would possibly think about using dynamic rendering you probably have a big web site with content material that modifications quickly and desires fast indexing. 

Or in case your web site depends on social media and chat apps that want entry to a web page’s content material. 

Or if the crawlers necessary to your web site can not assist a number of the options of your JS.

However actually, dynamic rendering is never a long-term resolution. You possibly can study extra about organising dynamic rendering and a few various approaches from Google’s guidelines.

Word: Google usually doesn’t take into account dynamic rendering to be “cloaking” (the act of presenting completely different content material to search engines like google and yahoo and customers). Whereas dynamic rendering isn’t superb for different causes, it’s unlikely to violate the cloaking rules outlined in Google’s spam insurance policies. 

How to Make Your Web site’s JavaScript Content material Website positioning-Pleasant

You possibly can comply with a number of steps to guarantee search engines like google and yahoo correctly crawl, render, and index your JS content material. 

Use Google Search Console to Discover Errors

Googlebot relies on Chrome’s newest model. But it surely doesn’t behave the identical manner as a browser.

Which implies launching your web site doesn’t assure Google can render its content material.

The URL Inspection Device in Google Search Console (GSC) can verify whether or not Google can render your pages. 

Enter the URL of the web page you need to check on the very high. And hit enter. 

Enter the URL site

Then, click on on the “Test Live URL” button on the far proper. 

Test live URL button

After a minute or two, the instrument will present a “Live Test” tab. Now, click on “View Tested Page,” and also you’ll see the web page’s code and a screenshot. 

Tested page view

Verify for any discrepancies or lacking content material by clicking on the “More Info” tab.

More info tab

A standard purpose Google can’t render JS pages is as a result of your web site’s robots.txt file blocks the rendering. Typically by chance.

Add the next code to the robotic.txt file to guarantee no essential assets are blocked from being crawled:

Consumer-Agent: Googlebot
Enable: .js
Enable: .css

Word: Google doesn’t index .js or .css information within the search outcomes. They’re used to render a webpage. 

There’s no purpose to block these essential assets. Doing so can forestall your content material from being rendered and, in flip, from being listed. 

Guarantee Google Is Indexing JavaScript Content material

When you affirm your pages are rendering correctly, guarantee they’re being listed. 

You possibly can verify this in GSC or on the search engine itself.

To verify on Google, use the “site:” command. For instance, exchange beneath with the URL of the web page you need to check:


If the web page is listed, you’ll see it present up in consequence. Like so:

indexed pages show in SERP

When you don’t, the web page isn’t in Google’s index.

If the web page is listed, verify whether or not a bit of JavaScript-generated content material is listed. 

Once more, use the “site:” command and embody a snippet of JS content material on the web page. 

For instance:

web "snippet of JS content"

You’re checking whether or not this particular part of JS content material has been listed. Whether it is, you’ll see it inside the snippet. 

Like this:

indexed JS content shown in SERP

It’s also possible to use GSC to see whether or not JavaScript content material is listed. Once more, utilizing the URL Inspection Device.

This time, somewhat than testing the dwell URL, click on the “View Crawled Page” button. And verify the web page’s HTML supply code.

View crawled page button

Scan the HTML code for snippets of JavaScript content material.

When you don’t see your JS content material, it may very well be for a number of causes:

  • The content material can’t be rendered 
  • The URL can’t be found as a result of JS is producing inside hyperlinks pointing to it within the occasion of a click on
  • The web page occasions out whereas Google is indexing the content material

Run a Website Audit

Usually working audits in your web site is a technical Website positioning finest follow. 

Semrush’s Website Audit instrument can crawl JS as Google would. Even when it’s rendered client-side. 

To start out, enter your area, and click on “Create project.”

Site Audit tool

Then, select “Enabled” for JS-rendering within the crawler settings. 

Enable JS-rendering in Site Audit

After the crawl, you’ll discover any points underneath the “Issues” tab. 

Issues tab overview

Widespread JavaScript Website positioning Points & How to Keep away from Them

Listed below are a number of the most typical points, in addition to some JavaScript Website positioning finest practices:

  • Blocking .js information in your robots.txt file can forestall Googlebot from crawling these assets. Which implies it may’t render and index them. Enable these information to be crawled to keep away from this drawback.
  • Google doesn’t wait lengthy for JavaScript content material to render. Your content material will not be listed due to a timeout error. 
  • Search engines don’t click on buttons. Use inside hyperlinks to assist Googlebot uncover your web site’s pages. 
  • When lazy loading a web page utilizing JavaScript, don’t delay loading content material that must be listed. Primarily concentrate on pictures versus textual content content material when organising lazy loading. 
  • Google typically ignores hashes, so ensure static URLs are generated for your web site’s webpages. Guarantee your URLs appear to be this: ( And never like this ( or this (

Take It a Step Additional

When you use what you’ve realized about JavaScript Website positioning, you’ll be nicely in your manner to creating environment friendly web sites that rank nicely and customers love. 

Prepared to dive deeper?

We suggest studying the next to study extra about JS and technical Website positioning:

Leave a comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More