Understanding JavaScript SEO: How to Make Your JavaScript More SEO-Friendly

2 years ago 110
ARTICLE AD BOX

Thanks to its advantages successful presumption of idiosyncratic enactment and acquisition — from creating dynamic content, animating images, controlling multimedia content, and much — JavaScript is progressively utilized successful eCommerce sites. 

However, with the maturation successful JavaScript usage comes much challenges for integer marketers, particularly those handling hunt motor optimization (SEO). 

Getting Google to scale Javascript contented is among the astir communal challenges successful technical SEO today. Despite pursuing each the rules of the game, galore tract owners inactive conflict to thrust integrated traffic, not realizing that their JavaScript SEO could beryllium the crushed why.

As an eCommerce integer selling agency, we’ve been intimately monitoring however this benignant of coding affects our clients and their wide SEO selling strategies. 

In this guide, we’ll stock our findings and tips connected overcoming immoderate of the biggest challenges with JavaScript SEO, by explaining:

  • What JavaScript is and however it works
  • Why JavaScript SEO is antithetic from accepted SEO
  • And which champion practices we urge for eCommerce sites

What is JavaScript & How Does It Work?

JavaScript (or JS, for short) is an highly versatile programming connection that tin beryllium utilized for everything from processing desktop applications to creating dynamic and interactive websites. It’s 1 of the 3 halfway technologies connected the internet, on with HTML and CSS.

JavaScript makes web pages “come to life,” truthful to speak. It’s utilized to personalize websites, present notifications, load caller contented arsenic your scroll toward the extremity of a page, and more. 

Popular websites similar Amazon, Walmart, and Target trust heavy connected JavaScript, acknowledgment to the galore advantages it offers, including

  • Improving website performance
  • Making websites much user-friendly
  • Enhancing wide idiosyncratic experience

Additionally, utilizing JavaScript tin effect successful accrued income for eCommerce sites. For example, studies person shown that adding a unrecorded chat widget to an eCommerce tract can summation income by up to 45%.

Common JavaScript Frameworks

Some fashionable JavaScript frameworks are React, Angular, and Vue.js. We’ll sermon a small astir each below: 

React

With more than 10 cardinal websites utilizing the software, React is 1 of the astir fashionable JavaScript frameworks retired there. Since its instauration to the marketplace successful 2013, it’s gained popularity arsenic a scalable, fast, and reusable model for gathering idiosyncratic interfaces that are some interactive and responsive.

React supports endeavor applications and is utilized by Netflix, Airbnb, and Facebook, among others. It supports the View portion successful the Model-View-Controller (MVC) conception and leverages front-end improvement for gathering affluent idiosyncratic interfaces for websites and apps.

React gained popularity owed to its easiness of use, particularly since it lone requires bundle engineers to person a basal knowing of HTML and JavaScript to usage it.

Vue.js

Vue.js rapidly gained popularity arsenic a front-end JavaScript model that is versatile, approachable, and fast. Its main absorption is connected gathering SPAs, oregon single-page applications.

The main payment of utilizing this model is its incremental usage model, meaning the model tin beryllium utilized successful constricted amounts, whereas others necessitate afloat adoption. Like React, Vue besides supports the View furniture of the MVC paradigm.

Additionally, the model allows developers to constitute leafage templates successful modular HTML. These templates (and different code) tin past beryllium packaged into components to streamline updates and for casual reuse.  

Angular

Angular (also known arsenic AngularJS) is simply a Typescript connection developed successful 2010 that includes JavaScript. It’s 1 of the astir fashionable frameworks utilized by companies specified arsenic Google, Forbes, PayPal, and more.

A broad framework, Angular offers everything from data-binding to routing. Angular focuses connected gathering SPAs that are some blase and businesslike and supports the MVC architecture.

With data-binding, information is automatically synchronized betwixt the lawsuit and the database. This allows developers to prevention clip and effort from having to specify UI requests and responses.

Angular besides supports dynamic rendering, which is beneficial for SEO. (We’ll sermon much of this aboriginal on.) It besides lightens the load connected an application’s server acknowledgment to its reliance connected the browser to physique the leafage – starring to quicker loading times.

One drawback: Angular is written successful a variant of JavaScript called TypeScript, starring to a longer onboarding clip if the bundle technologist is not acquainted with TypeScript.

How Google Processes JavaScript

Google processes JavaScript successful 3 stages: crawling, rendering, and indexing.

Googlebot (Google’s crawler) puts pages successful a queue for some crawling and rendering. 

Crawling is the process of discovering and indexing web pages. During this stage, the crawler scans done the pages connected the net to find caller and updated content.

When Googlebot retrieves a URL from the crawling queue by sending an HTTP request, it archetypal verifies that you’ve permitted it to crawl by speechmaking the robots.txt file. If the URL is disallowed, it avoids sending an HTTP petition and bypasses it entirely.

Rendering is the 2nd stage, during which the HTML, CSS, and JavaScript files that comprise a webpage are processed and turned into a format that tin beryllium easy work and indexed by Google.

Indexing is the 3rd stage, wherever rendered contented is added to Google’s scale and has the quality to look successful hunt motor results pages (SERPs).

What is JavaScript SEO?

One of the biggest advantages of utilizing JavaScript for eCommerce sites is that it tin assistance make a much seamless, user-friendly acquisition for website visitors. 

eCommerce websites are a fantastic illustration of dynamic contented delivered via JavaScript. For example, online retailers often usage JavaScript to load items into class pages and dynamically update products connected eCommerce sites. This makes sense; their inventory is successful a continuous authorities of alteration owed to sales. 

While this paints a rosy picture, JavaScript tin airs a situation for SEO.

Search engines tin tally into issues executing your JavaScript code, which means that definite leafage contented whitethorn not beryllium indexed oregon returned successful hunt results. Therefore, if your website is heavy reliant connected JavaScript and you don’t instrumentality the steps to hole your SEO, you whitethorn not spot an betterment successful your integrated performance.

In different words, without due SEO strategies, your tract whitethorn not beryllium crawled/indexed appropriately.

If you instrumentality JavaScript connected your eCommerce site, you’ll request to wage attraction to circumstantial areas of your tract to guarantee that your pages are some crawlable and indexable. This method process is called JavaScript SEO.

In galore ways, it’s the aforesaid arsenic accepted SEO. It helps your tract get crawled by hunt motor bots, truthful they’re much apt to beryllium served up to users successful the SERPs. It besides requires speeding up your leafage load times and troubleshooting immoderate JavaScript-specific issues that arise. 

However, the main quality betwixt JavaScript SEO and accepted SEO is the method challenges associated with JavaScript sites

In bid to process JavaScript, Google has added an other measurement (rendering) to its indexing process. If determination are immoderate issues with the JavaScript code, Google won’t beryllium capable to spot the contented to adhd it to its index.

JavaScript SEO Best Practices for eCommerce Websites

In the galore years that we’ve worked with eCommerce clients, our technical SEO audits person highlighted immoderate communal mistakes and galore opportunities for improvement.

Many dev teams we’ve worked with often don’t see SEO erstwhile gathering websites. Some don’t adjacent cognize astir SEO astatine all. They tin make great-looking websites that tally accelerated for the idiosyncratic — but aren’t capable to instrumentality into relationship what the bots request for indexing, resulting successful SEO-related issues aboriginal on.

So, present are a fewer JavaScript SEO champion practices to support successful caput erstwhile gathering oregon revamping your eCommerce website:

1. Use Dynamic Rendering

How your tract renders codification hugely impacts however Google indexes your JavaScript content.

Therefore, erstwhile strategizing your JavaScript SEO, you volition request to person a bully grasp of the antithetic ways JavaScript rendering occurs:

  • Server-Side Rendering (SSR): The rendered leafage is sent to the lawsuit (Googlebot, the browser, etc.). The method for crawling and indexing a website is akin to however it’s done for HTML pages, and JavaScript-specific difficulties should not exist. However, SSR tin beryllium challenging for developers and tin summation server load.
  • Client-Side Rendering (CSR): The JavaScript codification is executed by the lawsuit (the user’s browser oregon Googlebot). When the lawsuit has to render JavaScript, difficulties whitethorn originate erstwhile Googlebot attempts to crawl, render, and scale material.
  • Dynamic Rendering: A amended alternate to SSR and CSR, dynamic rendering allows you to present a website’s contented to users who entree it utilizing JavaScript codification generated successful the browser — but presents lone a static mentation to Googlebot. For this reason, we urge utilizing dynamic rendering connected your website alternatively of client-side rendering. It’s pre-rendering, but conscionable for hunt motor bots. 

2. Properly Route Your URLs

It’s important to update your URLs erstwhile updating content. 

JavaScript frameworks volition usage a router that allows you to representation to cleanable URLs. For this reason, we don’t urge utilizing hashes (#) for URL routing. This occupation is peculiarly prevalent successful aboriginal versions of Angular and Vue.

If you person a URL similar xyz.com/#something, thing that comes aft the hash is usually ignored by a server. 

If you usage the Vue router, see utilizing “History Mode” alternatively of “Hash Mode,” similar so:

const router = caller VueRouter ({

mode: ‘history’,

router: [] //the array of router links

)}

3. Follow Internal Linking Protocol

One of the astir communal problems we’ve seen is that developers usage JavaScript for links that Google cannot crawl, specified arsenic onclick oregon button-type links.

Here are a mates of examples:

  • Ex: <a href=”/good-link”>Will beryllium crawled</a>
  • Ex 2: <a href=”/good-link”onclick=”changePage(‘good-link’)”>Will beryllium crawled</a>

If you privation Google to observe and travel your links without checking, guarantee they’re successful plain HTML. Good, clean, interior linking is 1 of the indispensable factors for Google.

4. Use Pagination

Another extremity is to see each navigational elements successful your HTML response. 

You mightiness deliberation including your main navigation is communal consciousness and each that is needed — but footers and sidebars incorporate important contextual links and, therefore, request to beryllium included, arsenic well.

Pagination is particularly important successful eCommerce. While allowing users to scroll a provender infinitely is bully for idiosyncratic acquisition (UX), it’s not needfully SEO-friendly. Why? Because crawlers don’t interact with your leafage and truthful cannot trigger events to load supplemental content.

Eventually, Google volition halt scrolling oregon clicking the “View More” button, scope a bounds and determination on. This means your pages could get buried and not get crawled arsenic often, resulting successful mediocre SERP rankings.

We spot this circumstantial contented a batch with our clients and urge <a href> links instead, which let Google to spot the 2nd leafage of pagination. 

For example, debar utilizing <a onclick=”goto(‘https://xyz.com/bags/’)”>. Instead, spell with <a href=”https://xyz.com/bags/”>.

5. Lazy Load Your Images

While Googlebot supports lazy-loading, it does not “scroll” similar we humans bash erstwhile visiting web pages. Instead, Googlebot simply resizes its virtual viewport, making it longer erstwhile crawling web content. Therefore, the “scroll” lawsuit listener is ne'er triggered, and the contented is ne'er rendered by the crawler.

So, if you person respective images beneath the fold, it’s important to lazy-load them. That way, Googlebot tin inactive spot each your content. 

Below is simply a illustration codification that shows the IntersectionObserver API, which triggers a callback. A callback is mostly triggered connected the visibility of immoderate observed element. It’s besides comparatively much flexible and robust than the on-scroll lawsuit listener and supported by modern Googlebot. 

This codification works due to the fact that of however Googlebot resizes its viewport to “see” your content:

document.addEventListener(‘DOMContentLoaded’, relation () {

 Var perceiver = caller IntersectionObserver(lazyload, {

     threshold: 0.5

 });

 Var images = document.querySelectorAll(‘img’);

 for(var i=0; i<images.length; i++) {

   observer.observe(images[i]);

 }

});

6. Serve Unique Meta Data for URLs

For leafage ranking purposes, users request to beryllium served unsocial metadata (title, meta description, etc.) for each page. 

Each leafage connected your website should besides person a unsocial URL. Otherwise, hunt engines whitethorn beryllium crawling the aforesaid metadata for each leafage oregon nary astatine all. 

We counsel against utilizing fragments successful URLs for loading caller pages, due to the fact that Google mightiness conscionable disregard them. From a user’s perspective, a visitant mightiness cheque your “Our Team” leafage connected https://xyz.com#our-team, but a hunt motor volition apt disregard the fragment. This means that they won’t larn astir that URL.

Note that SPAs utilizing a router bundle similar vue-router oregon react-router necessitate other steps erstwhile it comes to changing meta tags portion navigating betwixt router views. 

7. Allow Googlebot to Crawl Your JavaScript

It seems simple, but if you’re accidentally blocking your JavaScript (.js) files from being crawled, Google won’t beryllium capable to render and scale that code. 

Review your robots.txt record to corroborate that your files are unfastened and disposable for crawling. You whitethorn usage the pursuing codification successful your robots.txt to let your resources to beryllium crawled:

User-Agent: Googlebot

Allow: .js

Allow: .css

This volition besides assistance you marque the astir of your crawl budget.

How to Evaluate Your JavaScript SEO

There are galore tools and guides retired determination for auditing your JavaScript codification and ensuring it’s decently optimized for hunt engines:

  • Google Webmaster Tools: Google’s suite of SEO tools (as known arsenic Google Search Console) tin assistance you optimize your tract and show your integrated performance.
  • Site: Search Operator: This bid volition lone amusement results from 1 tract successful the SERPs, allowing you to spot what is (and isn’t) being indexed by Google.
  • Chrome Dev Tools: These web developer tools are built into Chrome for easiness of use.
  • Ahrefs: This bundle suite includes tools for backlink-building, keyword research, and more.
  • Semrush: This level includes keyword probe and adjuvant resources connected each things SEO.

For much details connected moving a JavaScript SEO audit, cheque retired these adjuvant resources:

Get a JavaScript SEO Strategy for Your Business

Whether you ain an eCommerce website oregon a non-eCommerce one, you request to marque definite that your website’s pages are arsenic disposable and indexable arsenic imaginable to hunt engines, particularly erstwhile you’re utilizing JavaScript.

JavaScript has galore advantages for your eCommerce business, but besides comes with its ain acceptable of SEO challenges, adjacent for the astir precocious of marketers. Ignoring these tin pb to mediocre idiosyncratic acquisition and mislaid gross for your business. 

By pursuing the tips successful this JavaScript SEO guide, you’ll beryllium 1 measurement person to your website utilizing this codification successful the astir effectual mode possible. 

However, due to the fact that each website is unique, we urge hiring a nonrecreational to analyse your tract for you. Our eCommerce SEO services are designed to assistance you flooded communal JavaScript SEO issues, summation your integrated traffic, and amended business-critical leafage rankings. 

If you’re unsure however to code JavaScript SEO for your eCommerce website, our squad tin help. Contact our SEO experts anytime for a escaped audit and personalized connection for your online business.