JavaScript Rendering: What It Is and How to Handle It (original) (raw)

The success or otherwise of JavaScript rendering of your online content can impact your site’s performance, search engine visibility, and overall user experience.

In this article, we’ll explain:

What Is JavaScript Rendering?

JS rendering is the process of how a browser interprets and executes JavaScript code implemented on a webpage. And then transforms it into the resulting content the user sees displayed in the browser.

Similarly, in an SEO context, search engines will crawl, render, and index a site’s JS content. So it’s discoverable in users’ online search results.

So what is JavaScript?

JavaScript (JS) is a programming language for creating interactive websites (which contain more engaging user elements than traditional static sites) and web apps.

Further reading : Understand what JavaScript does and its different applications in our Basic Guide to JS.

JS is one of the most common computer languages for the web, along with HTML and CSS.

Your website branching into HTML or what do you want on your website, CSS or how do you want it to look, or JavaScript aka what do you want it to do.

Web developers use JS to add functionality to a site, including:

How Browsers Handle JavaScript

When you visit a page, a web browser (the software used to access websites) will generally handle JavaScript in three steps:

How Search Engines Render JavaScript

A search engine is software designed to help users search the internet. Different search engines handle JavaScript differently. Let’s see how the most popular ones do it.

Google

Google’s JavaScript rendering process takes place in three stages:

  1. Crawling: Discover a new page and download the text and media it contains
  2. Rendering: Execute the JavaScript code to understand the content of the page
  3. Indexing: Understand what the page is about and include it in the Google index

Here’s a visual summary from Google Search Central of what takes place when Google renders a site’s JS:

Google crawls, renders, then indexes.

Google’s web crawler, Googlebot, queues up webpages for crawling and rendering.

First, it assesses whether each page can be crawled. Googlebot then checks the rendered page for links. And queues any URLs it finds there for further crawling.

Bing

Bing doesn’t support all the latest JavaScript frameworks (collections of code libraries) for rendering.

The search engine’s official recommendation is for websites to use dynamic rendering instead of JavaScript.

What is dynamic rendering?

A website detects a visitor’s user agent (user-identifying software) to determine if it’s a human or a search engine crawler. It will render the content differently for humans and search engines.

When detecting Bing’s search engine crawler, websites should pre-render the content through server-side rendering (SSR). And then serve a static HTML website to the user.

Dynamic rendering means Initial HTML and JavaScript are rendered differently for browsers and crawlers

The advantage is that it minimizes HTTP requests (requests a user’s browser makes to the server) since the fully rendered page is delivered immediately.

Yahoo

Yahoo hasn’t disclosed official information on how its search engine renders JavaScript. But it does offer some advice on how websites should handle JavaScript:

Yandex

Yandex allows webmasters to choose whether to allow the search engine to render the JavaScript code on their pages.

The search engine recommends that websites use server-side JavaScript rendering.

How to Check if Googlebot Has Rendered Your Website Properly

In this section, we’ll focus on the most widely used search engine—and the one that plays a dominant role in SEO.

You can use the URL inspection feature in Google Search Console (GSC) to check if Google’s web crawler has rendered your website as it should.

Click on the search box at the top of the GSC dashboard, type in your website’s URL, and hit “Enter.”

example URL typed into the inspect URL field in google search console

The tool will check whether your site has been crawled. And if it’s eligible to appear in Google’s search results.

Click “View Crawled Page.”

view crawled page button highlighted

Next, click the “Screenshot” tab followed by “Test Live URL.”

Crawled page box open with Screenshot tab and test live url link highlighted

The tool will show you a screenshot of how Googlebot renders your website.

Screenshot appears of how Google renders the webpage

Compare the screenshot with how your website is rendered in the browser to check for any issues.

How Does JavaScript Impact SEO?

JavaScript rendering can have both positive and negative effects on your website’s SEO performance.

For instance, interactive website elements and dynamic content updates can provide a better page experience. Which Google tends to reward with better search engine results page (SERP) visibility.

Websites also use JavaScript to dynamically generate structured data—or schema markup—for webpages.

google serp listing for best snickerdoodle cookies with rich snippet data like an image of cookies, star rating, and time to bake.

While not a confirmed Google ranking factor, structured data can play a part in improving your search engine visibility.

But, without proper implementation of JavaScript code, JS rendering can have its SEO downsides.

The results?

3 Methods for Handling JavaScript Rendering

If your website uses JavaScript (and it most likely does), one crucial aspect you need to figure out is how it will render JS code. This decision can ultimately affect your website’s performance and the overall user experience.

There are three JavaScript rendering methods you can choose from: client-side rendering, server-side rendering, and static site generation.

All three methods have their pros and cons, which we’ll get into next.

Client-Side Rendering (CSR)

In CSR, JavaScript code is executed in the user’s browser instead of on the server side.

When a user visits a website, the site’s server responds with an HTML file containing only the basic structure of the page. Along with links to JS and CSS files.

The user’s browser then downloads the files and executes them locally, rendering the website.

Pros and Cons of Client-Side Rendering (CSR)

The advantages of CSR include:

But CSR also comes with its set of disadvantages:

Server-Side Rendering (SSR)

SSR works by having JavaScript executed on the website’s server.

First, a user visits a URL using their browser. The browser requests the webpage from the server. And the server renders the page completely, sending it back to the browser.

Pros and Cons of Server-Side Rendering (SSR)

JavaScript server-side rendering offers:

Meanwhile, the main disadvantage of server-side rendering is it can cause a heavier load on a website’s server, especially during periods of high traffic. This can slow down your website or even make it inaccessible.

Static Site Generation (SSG)

With SSG, websites are served as static files—meaning exactly as stored on the website’s server and without any server-side processing.

Rendering happens on the website’s server. But unlike in SSR, it occurs before a user even makes a request.

Pros and Cons of Static Site Generation (SSG)

Static site generation allows for:

Static site generation also has a couple of downsides:

How to Analyze Your JavaScript Website

Use Semrush’s Site Audit tool to uncover various issues that could prevent your JS-powered website from achieving higher search engine rankings.

Enter your website domain and click “Start Audit” to check your site.

Site Audit tool

You’ll be able to customize settings for the audit, including:

Make sure to enable JavaScript rendering in the “Crawler settings” section.

JS rendering section of site audit settings highlighted

Then, click on “Start Site Audit.” The tool will generate a report detailing the overall health of your website.

Click the “Issues” tab. Type “JavaScript” in the search box to filter by JS-related concerns.

site audit shows javascript issues such as slow load speed, broken internal JavaScript and CSS files, and unminified files.

From here, select any issue to review the list of pages that have it. Some common problems you might encounter are:

Alternatively, click “Why and how to fix it” next to each issue type to learn how to address it.

450 issues with unminified JavaScript and CSS files highlighted with pop up describing the issue and how to fix it.

Sign up for a free Semrush account today to start improving your JS website’s technical and organic performance.