Guide // Developers

Detect adblock with JavaScript without maintaining the detection

JavaScript on your page can tell whether a visitor is blocking ads. The hard part is keeping that answer right: blockers and filter lists change, and a check that breaks throws no error. It reports "no blocker". You can own that upkeep yourself, or read a maintained result in your code through an API.

Free plan: 5,000 detections a month, no payment method.

Reviewed · By AntiAdBlock Core · We make adblock detection

Two jobs, one answer

01 // The check Someone keeps it current as blockers change

02 // Your logic What your page does with the answer

A snippet leaves 01 to you. The Detection API leaves you only 02.

Why copy-paste adblock detection stops working

The public snippets and libraries we checked rely on one of two old families of checks: fake ad elements and test requests. Both are public, so the people who maintain filter lists know them too.

What breaks, and how you find out
What happensWhat you seeWhat it costs
Filter lists add rules that switch well-known detectors offNothing. The check still runs and reports no blockerYour ad-block rate falls while blocking does not
Ads are blocked by an office network or a VPN, not by the readerThe same message as someone who installed an extensionA reader who cannot switch it off gets a request they cannot act on
Nobody is assigned to keep it currentYou notice later, in your ad reportsUpkeep becomes a recurring job on someone's desk

A published detection script starts ageing the day it ships, and nothing tells you when it stops working. Blocking also comes built into browsers: Brave blocks third-party ads and trackers by default with its own engine, and Firefox includes tracking protection that blocks many ad and analytics domains.

Adblock detection libraries in 2026: where they stand

Four packages you are likely to find on npm. Versions and dates come from npm and GitHub, read on November 1, 2026; BlockAdblock and FuckAdBlock, from our comparison.

Last release of each package
PackageLatest versionReleasedRepository
blockadblock3.2.1March 2016Last commit in December 2018
fuckadblock3.2.1March 2016Same project as BlockAdblock; no commit on its main branch since October 2017
just-detect-adblock1.1.0October 2020Describes itself as a copy of BlockAdblock and FuckAdBlock; last commit in October 2020
adblock-detect-react1.3.1January 2024A wrapper for React; last commit in January 2024
Each package, blockadblock.com and Manifest V2 in Chrome
  1. BlockAdblock and FuckAdBlock 3.2.1
  2. blockadblock.com: the technology is sold and its updates stop
  3. just-detect-adblock 1.1.0
  4. adblock-detect-react 1.3.1
  5. Chrome 138 turns off Manifest V2 extensions for everyone, for good
  6. The last Manifest V2 extensions leave the Chrome Web Store

npm, GitHub and Chrome for Developers, Nov 1, 2026; our BlockAdblock comparison, Oct 11, 2026.

The newest release here is from January 2024. Blockers and filter lists have changed a lot since then, including Chrome turning off Manifest V2 in July 2025, and AdGuard alone publishes hundreds of filter changes a week. A library that ships no releases does not change with them, and many carry bug reports left open for years.

Packages keep being installed long after anyone updates them. On a site that earns from ads, someone has to own the upkeep.

What your code needs from a detection

Your code only cares about the answer. Before you pick a library or a service, ask four questions of what it returns:

  1. Does it answer on every page, including "no blocker"? Without that, a clean page and a check that never ran look the same.
  2. Does it say what kind of blocking it found? An extension can usually allow one site; a DNS filter such as Pi-hole usually can't be switched off in one click.
  3. Does it give the browser family? So your instructions match the reader's browser.
  4. Is its silence documented? With no answer, your page takes its normal path: fail open.
From your page to your code // one result per page
  1. Your page Opens as usual
  2. Our tag Runs the check
  3. One result Per page
  4. Your code Decides
The fields your code reads
FieldWhat it tells your codeValues
detectedWhether this page view has a blockertrue, false
blockerTypeThe kind of blocking it foundextension, brave_shields, browser_protection, network_dns, unknown
browserThe browser family, so your message matches itchromium, firefox, edge, brave, webkit, other

All fields, in the reference.

Get the result in your JavaScript with the Detection API

The AntiAdBlock Core Detection API is a script mode you choose per site on the Max and Business plans. The same tag runs our multi-signal engine, maintained daily. Nothing appears on screen, and on each page your JavaScript receives one result through the aabc:detection event, the AABC_ON_DETECT callback or the AABC_DETECTION snapshot.

The whole integration: your function, then the tag
<script>
window.AABC_ON_DETECT = function (result) {
  // Your logic here.
};
</script>
<script async
  src="https://antiadblockcore.com/s/SITE_ID.js"
  data-aabc-site="SITE_ID"
  crossorigin="anonymous"></script>

1. Your code, before the tag 2. Your tag, from your dashboard

From the Detection API reference. SITE_ID is your site's ID.

Switch the site to Detection API under Script mode in its settings and keep the tag: the reference has each step, and you can test your code without a blocker. The API comes with Max ($12.99 a month) and Business; the Free plan (5,000 detections a month, no payment method) runs the same engine with the wall, so you see your ad-block rate first.

No code at all? In its default mode the tag shows a wall that asks readers to allow your site: see the adblock detector, and the anti-adblock script guide for building versus buying.

Max and Business plans // prices in USD // compare plans

React, Next.js, Vue and WordPress

You do not need a framework package. The result is a plain browser event on window, so any stack can read it.

One tag per page, whatever the framework
StackWhere the tag goesWhere you read the result
Any site or CMSThe <head> of every pageA callback or listener placed before the tag
React and Next.jsOnce; in Next.js, in the head of the root layoutA client component, keeping the last result in state
Vue, Svelte or plain JavaScriptOnce, in the page's headListen for the event and read the snapshot
WordPressThe AntiAdBlock Core plugin adds it to every pageYour theme script: the snapshot and the event

In single-page apps the result arrives when a page is opened or reloaded, not on client-side route changes: keep the last result in your app state. The reference has a React hook and a Google Tag Manager recipe.

The wall, the API or your own code: which fits

Four ways to go from here
If you wantUseStart here
Your code decides what blocked readers seeThe Detection API, on Max and BusinessDetection API
Ask readers to allow your ads, no codeThe adblock detector and its wall, from the Free planAdblock detector
See it working before installingThe live demo, with your own blocker onLive demo
Keep your own snippetOwn the upkeep yourselfCompare with BlockAdblock

With AntiAdBlock Core, the dashboard shows your ad-block rate and daily activity on every plan; the breakdown by type of blocking comes with Max and Business.

Frequently asked questions

Can JavaScript detect every ad blocker?

No detector can promise every blocker on every browser, and a check written once covers only the blockers it was tested against. AntiAdBlock Core maintains its engine daily, with 99.7% declared detection precision.

Why did my adblock detection stop working without an error?

Most likely a filter list added a rule that switches it off, or your readers' blockers changed. The script keeps reporting that nobody is blocking: your ad-block rate falls while ad revenue does not rise.

Does a reader behind an office network count as an adblock user?

The page is blocked all the same, but that reader usually can't switch it off in one click. The Detection API reports it as its own blocker type, network_dns, so your page can show a short note, or nothing.

Can I detect adblock on the server, or in PHP?

Not on its own. The blocker runs in the visitor's browser or network, so the answer comes from the browser, where the Detection API hands it to your JavaScript. Access rules for paid content belong on your server.

Can I replace a detection library without rewriting my page?

Mostly, yes. Remove the library, add your site's tag or the WordPress plugin, and on Max or Business switch the site to the Detection API. Your callback code moves into window.AABC_ON_DETECT, defined before the tag.

Sources

With the date each one was read.

  1. Chrome for Developers: Manifest V2 support timeline
  2. Brave blog: Brave's own ad-blocking engine
  3. MDN: Firefox tracking protection
  4. npm registry and GitHub: latest version, release date and last commit of each package
  5. AdGuard filters repository on GitHub: filter changes per week
  6. AntiAdBlock Core vs BlockAdblock: the library and the script, source by source

Hand off the check, keep your logic

Try the engine on Free and watch your ad-block rate. When your code is ready, turn on the Detection API for that site on Max or Business.

Prices in USD // see pricing

Keep reading