web-design

How Well Do Search Engines and JavaScript Get Along

JavaScript, years ago, wasn’t as widely accepted as it is today. The programming languages were blocked then, the ad popups taking all the blame. And the scenario today gives JavaScript the full credit of a website being popular. Mobile Internet lives on JavaScript these days, utilizing the features it can support like geo-locations, navigation and media player. When JavaScript and Search engines combine, what must one focus on? Let’s find out!

Search Engines Have Learned

A point worth being mentioned here is that those times, when one was unable to match JavaScript and Search engines, are gone. Search engines are now of improved versions, though back then content via JavaScript was not supported by Search engines. Speaking of Search engines, Google is the obvious buzz that’s in the spotlight.

JavaScript means no hiccup by default to a giant like Google. But this doesn’t make JavaScript a completely safe option. No doubt, Google keeps the working of its search algorithm confidential but the following can be inferred for now:

Loading Content via Load Instead of User Events

Sometimes, a website’s content through JavaScript are altered by events. Content via Load events is taken into consideration by the Search engines.

When the website’s DOM tree is loaded, the outcomes are fired from the browser. Search engines such as Google itself permits the loading of events during crawling. This allows the site content to be indexed once the execution of the load events is fulfilled.

However, user-events are not loaded. So, actions like clicking or touching the events and subsequent changes are not considered while indexing.

Push-States and URLs

A URL allows the accessibility to a site for Google to index it. Since click events make the content appear when an individual user triggers them, they cannot be considered too.

One can possible influence a site’s URL using JavaScript’s push state API. JavaScript allows you to have an overview of the entire site’s navigation, with the help of ‘pushstate()’ to modify the URL in the browser. You can simultaneously load and replace the content using JavaScript.

Every URL created using push state must have a real and existing URL since Google cannot index exclusively realized URLS through push state API.

This works for Social networks as well. Sites that have a real URL can be shared. Apps like Facebook and Twitter fetch content from a site, possible only with a real URL.

Use pushState() to make the right URLs and make sure the right content is put up via JavaScript. One wrong step, with a URL that doesn’t load any new content can result in double content. This is disliked by the Search engines.

Don’t Exclude JavaScript

Apparently, this point is a well-known fact. Obvious as it is, do not exclude JavaScript files for Search engines. The Search engines cannot access those of which prohibit JavaScript files, for example, ‘robots.txt’.

Since the JavaScript does not involve indexable content itself, it is mostly not seen by the search engines.

Progressive Enhancement

If you are to let in the content created via JavaScript and most of the Search engines gives you all hopes and options to do so, consider this: The safest method is the ‘Progressive environment’

The focus here is to make content that is easily available, irrespective of the crawler or the browser.

Basically, the entire content that includes texts, images, etc. that’s searched on a search engine must work even without JavaScript.

This counts the web developer’s extra effort. Websites here need to make the content available without JavaScript. A leeway could be allowed at times where only important content without JavaScript could be displayed depending on its type and preparation.

You need to guess the kind of effort that is practical for your project.

Correct Semantics

With and without JavaScript: Your content must be labelled semantically right. The labelling of the headings using respective HTML elements must be done accurately.

The rules that apply to normal content are the same that work here. The HTML source code text is the key factor Google looks for after the JavaScript is executed. The right elements play an important role in this process.