JavaScript Google SEO Test Setup

JavaScript Google SEO Test Setup

By documenting the JavaScript SEO test here it will break the current SEO test.

On this SEO Test webpage I added the following HTML content (added via the WordPress Post edit form):

<strong class="reptest">More Spectacular Tests</strong>

Normally the text “More Spectacular Tests” would be visible when the relevant WordPress Post is loaded in a web browser like Google Chrome.

I also loaded a JavaScript file:

<script src=""></script>

With the following code:

function hasClasss(e, c) {
if (typeof e === "string") e = document.getElementById(e);
var classes = e.className;
if (!classes) return false;
if (classes === c) return true;
return"\\b" + c + "\\b") !== -1;
function reptests(){
var spans = document.getElementsByTagName('strong');
for (var i = 0; i<spans.length; i++){
if (hasClasss(spans[i], 'reptest')){
spans[i].innerHTML = '<h4 id="more">More Marvelous SEO Gold Tests</h4>';
window.addEventListener('load', function (){

The way this JavaScript code works is after the HTML source code has loaded in a webpage (after Googlebot has access to the webpage) it searches through the HTML code for the class reptest and replaces the content of the tag (in this case a strong tag) with some content from the JavaScript File. On our test webpage there’s a single strong tag with the reptest class, when viewing the webpage the JavaScript code completely replaces the content of the strong tag with some content stored within the inlinks.js file.

In simple terms the JavaScript looks for reptest and replaces this code:

<strong class="reptest">More Spectacular Tests</strong>

with this code:

<strong class="reptest"><h4 id="more">More Marvelous SEO Gold Tests</h4></strong>

There can be a short delay between the page loading and the text being replaced, go to the SEO Test webpage, find the text More Marvelous SEO Gold Tests and refresh the page a few times.

There’s a fair chance you’ll see the text More Spectacular Tests change to More Marvelous SEO Gold Tests.

Which content will Google index and rank SEO wise, what we see when viewing the HTML source code

“More Spectacular Tests”

or what we see in a browser window

“More Marvelous SEO Gold Tests”

which was generated using Javascript?

See the JavaScript SEO test results.

Continue Reading SEO JavaScript Tests, What Can Google Index?