JavaScript cloaking is when scripts decide what a visitor sees. A crawler that does not run JavaScript gets the plain HTML, a browser that does gets a different page, or is redirected.
How it works
From the Google study of ten cloaking services (Cloak of Visibility):
- Three used JavaScript execution to block rudimentary crawlers.
- JavaScript also serves as the delivery method for redirects.
- One service let the operator add custom JavaScript fingerprinting code that runs on every visit.
In the paper’s measurement in the wild, “Has JavaScript support?” scored 22.4% for Google Search URLs and 49.6% for Google Ads URLs.
Study from 2016. [TODO: newer source]
Not cloaking by itself: Google tells sites that use JavaScript to make that content accessible to search engines and users without cloaking (Google spam policies).
How to spot it
Compare the page with JavaScript off and on. Free: website cloaking checker runs both. By hand: curl for the raw HTML, a headless browser for the rendered page (curl guide).