Courtney-Dale Nel
Courtney is a Content Writer on the Pure SEO team. They have a Bachelor in Behavioural Psychology, way too much experience working with pigeons, and a fondness for nachos that rivals most marriages.
If you’ve ever opened up a website and immediately encountered a bright and shiny animation, or a pop-up prompting you to another page, then you already know at least some of what a JavaScript-enabled website can do.
Modern web developers and digital marketing professionals are constantly looking for ways to make websites more dynamic and interesting for the users who come across them, and JavaScript is the language that allows them to do it. JavaScript—while arguably not a programming language in its own right—is the key to making a website interactive and engaging.
However, despite the fact that JavaScript is implemented on 95% of all websites, there is a significant portion of people in the online industry who don’t know how to optimise their JavaScript-enabled website.
JavaScript (JS) has a variety of applications. In terms of website creation, it is lines of code written into the HTML that constructs a website that can communicate directly with a web browser. Instead of executing commands on its own, it tells the browser what to load and where, and the browser does all of the hard work.
JavaScript allows developers to include features that turn a webpage from a simple page of information into an interactive experience, including things like:
Imagine that the webpage is a stage play: the HTML is the story being acted out on stage, and the JavaScript is the props, set, and music that brings it to life. The story can be played out without all of these peripherals, but it tends to look a bit flat. Like Les Misérables without the costumes, or Tchaikovsky without his cannons.
That makes you the stage manager; the invisible orchestrator behind the scenes making sure that everything runs smoothly. And if you want people in the audience, there are some things you need to do to get your production found.
The only way to get people to your website from a SERP is to make sure it is indexed. “Indexing” is Google’s method of storing websites to serve as search results, and if your site is not in that digital Rolodex then you’re going to miss out on users. That’s why SEO exists: to ensure your website can be seen by the search engine, which in turn presents it to your ideal users.
So, how do you make sure that each page of your website is indexed when JavaScript is added into the mix? Let’s take a look.
There is one rule here: what cannot be seen cannot be indexed. A robots.txt file is like a directory for the web crawlers that will visit your site, sending them through your pages and telling them what to miss out. Use your robots.txt file to provide web crawlers with as much of the same information users see as possible.
This helps Google to understand the user experience on your website, and since they want their users to be happy, they will rank a site with good UX higher on its results page. While you can choose to redirect crawlers away from JavaScript-enabled pages, hiding your JavaScript can make you go down in rankings because Google thinks you’re cloaking something.
You can manually check to see if Google can index your content using their Index Coverage report in GSC.
Some search engines can’t render JavaScript at all, and therefore cannot index websites that use it. Google can, but it can only index what has been rendered. If your site isn’t indexed then it’s not going to be found, so it’s crucial to test how it renders in different environments!
To do that, you need to know what a DOM is. The Document Object Model (DOM) is a tool that Google uses to break down web pages’ code and subsequently render them. In essence, it’s an example of what Google “sees” when it looks at your page. You can use the DOM to test if all of your scripts are running properly, and to resolve any breaks in the code should the element not show up.
If there is a massive JavaScript file that has to load before the base HTML can load, then the rendering of the site is going to be significantly delayed. This is bad to Google, as the search engine values user experience and therefore emphasises how quickly a page loads readable content.
So what do you do? Instead of linking a file to existing HTML, write the JavaScript into the HTML code so that it renders alongside. Also, make sure to test your page speed across multiple environments and on mobile devices (Google uses mobile-first indexing).
If there is one thing to take away from this guide, it is test, test, test. No matter what changes you make, you need to be sure that Google can see them as your user does and accurately rank your page in the SERP. Don’t let the amazing elements of your website get lost in a miasma of misfortune!
As the top search engine optimisation company in New Zealand, we have a team of experts who have been neck-deep in Google’s rules and regulations for years. If you’re not sure how to approach making sure your site has been indexed properly, just give us a call and we’ll take it from there.