SEO for JavaScript: An experiment to test search engines

This article examines the best SEO resources for JavaScript and a test to understand how search engines (Google, Bing and Yandex) behave when they have to crawl and index pages rendered through JS. We wil also look at some considerations dedicated to SEO experts and developers.

JavaScript is a major player on today’s web, and as John Mueller said, “It won’t go away easily.

The JavaScript topic is often vilified by the SEO community, but I believe it is due to a lack of technical skills in JavaScript development and web page rendering. But this also depends on the difficulty of communication between SEO experts and development teams.

This post is divided into two parts: the first (short) offers some resources to look at the topic in more detail; in the second (more in-depth) we look at a very simple experiment that tests search engines on a web page rendered using JavaScript.

Some resources that introduce SEO for JavaScript

In the following video Martin Splitt, referring to Google, introduces the topic, explaining the importance of thinking from an SEO perspective when developing projects in JavaScript. In particular, he refers to pages that render critical content in JS and to single-page apps.

 

 

“If you want assets to be indexed as soon as possible, make sure the most important content is in the page source (rendered server side).”

What’s the reason? Because we must always keep in mind the following scheme, that is the two waves of indexing.

The flow of crawling, indexing, rendering and reconsideration. And the two waves of processing.

The flow of crawling, indexing, rendering and reconsideration. And the two waves of processing.

 

Content generated by JavaScript is considered in the second wave of indexing, because it has to wait for the rendering phase.

In the following video, however, basic SEO tips on projects developed in JavaScript are explained.

 

 

“We are moving towards extraordinary user experiences, but we are also headed towards the need for ever greater technical skills.”

A simple test to clarify how search engines treat JavaScript

I will describe a test that I performed just to retrace the steps described by the Google documentation (crawling, indexing, rendering, reconsideration). A test, however, that also extends beyond the Mountain View search engine.

Note: it is a fairly “extreme” test in terms of the technical solution applied, and it was made using simple JavaScript functions, without the use of particular frameworks. The aim is solely to understand the dynamics of the search engine, not an exercise in style.

1) The web page

First, I created a web page with the following characteristics:

$(document).ready( function () {
  hydration();
});

2) Submission of the page to search engines and testing

After I published the page, I reported it to search engines, and in particular to Google (through the “URL check” of Search Console), to Bing (through “Submit URL” of Webmaster Tool) and to Yandex (through “Reindex pages” of Webmaster Tool).

At this stage, I ran some tests.

Merkle Fetch & Render: rendering test tool

Merkle Fetch & Render: rendering test tool

 

The DOM generated by the Google Rich Results Tes

The DOM generated by the Google Rich Results Tes

 

3) Indexing

At this stage, all search engines behaved the same: after a few hours, the result was present in all SERPs.

The snippet generated in the first phase on Bing, Yandex and Google

The snippet generated in the first phase on Bing, Yandex and Google

 

The snippets, as seen in the images, are composed of the content of the <title> tag and a description obtained from the data available in the main content.

No images on the page have been indexed.

4) Editing operations, sitemap, Google indexing API

The next day, the snippets were the same. I have completed some actions to send signals to search engines.

[oc-redirect num=1]

The results

What happened after a few days?

Google rendered and reworked the snippet

Google rendered and reworked the snippet

 

1) Google rendered the content by processing the JavaScript, then reworked the result on the SERP using the content correctly.

Google has indexed the rendered content using JavaScript

Google has indexed the rendered content using JavaScript

2) The first image of the post was also indexed and appeared on Google Images.

The post image, rendered via JavaScript, appears on Google Images

The post image, rendered via JavaScript, appears on Google Images

 

3) The snippets on Bing and Yandex have not changed. This means that in the days following the publication they did not consider the final DOM.

4) The image shown in the link for the preload did not receive favorable treatment as compared to the other.

JavaScript page rendering (β) by Yandex

In the Yandex webmaster tools there is a “beta” feature that allows you to specify the behavior of the robot when it crawls pages.

The Yandex rendering configuration panel

The Yandex rendering configuration panel

 

You can suggest running the JavaScript to complete the rendering, or not running it. The default option gives the algorithm the “freedom” to choose the best action.

In the specific case where almost all of the content is generated on the client side, but more generally, for example for a JavaScript framework, it is advisable to force the rendering.

Dynamic rendering

In the last phase of testing, I implemented a dynamic rendering solution for Bing and Yandex. This solution allows to differentiate the response that is sent to the client so that:

How dynamic rendering works

How dynamic rendering works

 

After completing the implementation, I requested indexing again through the Bing and Yandex tools.

Yandex, in a few hours, rebuilt the snippet in SERP as follows. So Yandex considered the new version rendered server side.

The Yandex snippet after dynamic rendering

The Yandex snippet after dynamic rendering

 

Bing did not change the result in the time available for the test, but certainly (ehm.. at least I hope) would have integrated it in the following days.

Conclusions

This simple test demonstrates that Google works as the documentation specifies, respecting the two phases of the scheme seen in the initial part of the post. In the first phase, in fact, it indexed the content present in the page source almost instantly (the HTML generated on the server side); in the second, in a couple of days, it indexed the parts rendered via JavaScript.

Bing and Yandex, on the other hand, do not seem to detect content generated via JavaScript .. at least in the days following publication.

These elements highlight some JavaScript-related aspects that I’ll try to explain in a little more detail below.

“The question is .. is it worth introducing such “complexity” into a project?  The answer is simple: yes, if we are going to produce an amazing user experience!”

Additional Notes

Good JavaScript, and good SEO!