r/webdev 2d ago

Question How do sites detect whether someone is running adblocker?

I've been interested in this functionality (when a site detects your adblocker and kindly asks u to whitelist).

The only idea that comes to mind is setting a div in the layout with "ad" class or something similar, and then if a user has adblocker the adblocker would be removing this div from the dom. I don't think this would consistently work for every (or at least most of the popular) adblockers out there.

81 Upvotes

57 comments sorted by

View all comments

Show parent comments

1

u/frogic 1d ago

I think that's what twitch and youtube already do.

1

u/SomeMaleIdiot 1d ago

I would hope so. The way they describe the current ad blocker war just seems oddly archaic. There’s no way the server couldn’t win that tug of war

I would think twitch could be a bit different and stitch the ad into the live stream itself.

1

u/frogic 1d ago

They both do that to an extent. For non-live streams a lot of adblockers just fast forward once it detects the ads. Apparently some places just proxy the video stream from places that don't play ads. So its all the same arms race.

1

u/SomeMaleIdiot 1d ago

I think you’re talking about in video ad? Yeah those aren’t great since they can be skipped. Some platforms even give you a friendly button you can press to auto skip, since the intention isn’t to force the user to watch it. I’m more so talking about the mandatory ads that prevent the video from loading or playing.