Official: Google and JavaScript

Google has released another document about JavaScript this month. Should you use JavaScript on your web pages? Does JavaScript cause ranking problems?

Official: Google and JavaScript

Google tries to render JavaScript on your pages

If the HTML content of your web pages does not contain URLs or real content, Google tries to render the JavaScript on the web page:

“Crawling a URL and parsing the HTML response works well for classical websites or server-side rendered pages where the HTML in the HTTP response contains all content.

Some JavaScript sites may use the app shell model where the initial HTML does not contain the actual content and Googlebot needs to execute JavaScript before being able to see the actual page content that JavaScript generates.”

JavaScript rendering takes a lot of time

Google says that it can take several seconds to render a page:

“Googlebot queues all pages for rendering, unless a robots meta tag or header tells Googlebot not to index the page. The page may stay on this queue for a few seconds, but it can take longer than that.”

Once Googlebot’s resources allow, a headless Chromium renders the page and executes the JavaScript. Googlebot parses the rendered HTML for links again and queues the URLs it finds for crawling. Googlebot also uses the rendered HTML to index the page.

Google recommends pre-rendering

Although Google tries to render JavaScript pages, many webmasters have reported that this does not always work as expected. Google also recommends that your web server should deliver pre-rendered pages so that search engine bots can read the content:

“Keep in mind that server-side or pre-rendering is still a great idea because it makes your website faster for users and crawlers, and not all bots can run JavaScript.”

Web page speed is a ranking factor. If your web server pre-renders your pages, you can be sure that search engine crawlers find the right content, and your web pages will be faster.

Google does not support all JavaScript features

This is another reason to pre-render your web pages: Google might not be able to process all of your JavaScript commands:

“Googlebot has some limitations regarding which APIs and JavaScript features it supports.”

If your web pages do not rely on JavaScript to show the content, it is much more likely that Google will find all of the content.

You should use meaningful HTTP status codes

Although website visitors cannot the see HTTP status code that a web page sends, it is very important that your pages use the correct HTTP status codes:

“Googlebot uses HTTP status codes to find out if something went wrong when crawling the page.

“You should use a meaningful status code to tell Googlebot if a page should not be crawled or indexed, like a 404 for a page that could not be found or a 401 code for pages behind a login.”

The website audit tool in SEOprofiler checks the HTTP status codes of your web pages. It also shows errors that have a negative influence on your web page rankings.

JavaScript is great, but you should not rely on it

Use JavaScript to enhance your website but do not use it to display the main content of your web pages. If you want to be 100% sure that search engines can find the content on your web pages, your content should be visible even if JavaScript has been disabled.

The website audit tool in SEOprofiler shows you how search engines see your web pages. You can create your SEOprofiler account here:

Analyze your web pages now

Johannes Selbach

Johannes Selbach is the CEO of SEOprofiler. He blogs about search engine optimization and website marketing topics at "http://blog.seoprofiler.com".