Mobile app version of vmapp.org
Login or Join
Ann8826881

: Googlebot encountering JavaScript errors due to rendering outdated HTML files with newer JS files We recently encountered an issue where we added a JavaScript variable (e.g. var GLOBAL_VAR = true;)

@Ann8826881

Posted in: #Googlebot #Javascript #WebCrawlers

We recently encountered an issue where we added a JavaScript variable (e.g. var GLOBAL_VAR = true;) to an HTML page (e.g. /Search/Index) and updated the separate JS file (e.g. /Scripts/search/index.js) to access and use that JS variable. After publishing these changes live to the web, we began getting JS errors generated by Googlebot that are sent to us by our window.onerror function. The errors are like:


Uncaught ReferenceError: GLOBAL_VAR is not defined

Line #: 1

example.com/Scripts/search/index.js

When I visit the /Search/Index page on our site, I clearly see the new JS variable is there and defined.

It's almost as if when Googlebot is crawling our site, it isn't detecting that the HTML page changed. So that means it is using old, cached HTML that doesn't include the setting of the GLOBAL_VAR variable, which causes the JS error.

We published the HTML/JS changes on 2/6, and we are still getting JS errors as of 2/10. I would have thought Googlebot would recognize the HTML changes by now. We've never experienced this problem in the past.

Why would Googlebot not update their cache if the HTML of a page changes? Most importantly, how can we get Googlebot to detect the HTML changes and update their cache, so we stop getting these JS errors?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Ann8826881

1 Comments

Sorted by latest first Latest Oldest Best

 

@Mendez628

The easiest way to solve this is to version your JavaScript files. Then only new pages will fetch the new JavaScript.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme