is-headless-browser v1.0.0
is-headless-browser
An ES5-compatible NPM package that uses lightweight heuristics to detect headless browsers and browser automation tools.
Quick Start
Run
npm i is-headless-browser
And add for your page
import { isHeadlessBrowser } from "is-headless-browser";
if (isHeadlessBrowser()) {
// display content for bots
} else {
// display content for real users
}
See example.html
Limitations
This package functions by checking for the presence of well-known properties, such as navigator.webdriver, which are indicative of browser automation tools. It is designed to be compact and quick to execute while minimizing false positives by leveraging the most reliable indicators of automation.
These checks are not intended to detect sophisticated automation tools that use advanced evasion techniques, such as Puppeteer with Stealth Plugin. If you need to detect such tools, be prepared for greater complexity and computational overhead, such as intercepting the execution of native browser functions using Proxy (like brotector) and such.
References
8 months ago