How To Detect Adblock Using jQuery

Hello friends, In this article, we learn about Adblock.

What is Adblock?

  • Adblockers don’t block ads – they block internet requests that transfer content into the browser.
  • Ad blockers use filtering rules to dam or hide contents on an online page.
  • While a webpage is loading, the ad blocker appearance at the site’s scripts and compares them with a listing of websites and scripts it absolutely was designed to dam. If it finds any, it blocks them.

How to add an Adblock extension?

Step: 1

You have to open your google chrome web store.

Step: 2

After that, you have to search Adblock in the search box and click on Adblock.

Step: 3

Next, you have to click the Add to Chrome button.

Now we are creating a simple demo for detecting Adblock on a page using jQuery.

<script src=""></script>
<link href="" rel="stylesheet">
<div class="alert alert-success" id="success" style="display:none;">
  <strong>No AdBlock is used on this page.!</strong> 
<div class="alert alert-danger" id="danger" style="display:none;">
    <strong>AdBlock is enabled on this page.!</strong> 

async function detectAdBlock() {
  let adBlockEnabled = false
  const googleAdUrl = ''
  try {
    await fetch(new Request(googleAdUrl)).catch(_ => adBlockEnabled = true)
  } catch (e) {
    adBlockEnabled = true
  } finally {
    <!-- console.log(`AdBlock Enabled: ${adBlockEnabled}`) -->


On this page, I have not used AdBlock.

On this page, I have used AdBlock.


In this article, we have learned about what is Adblockhow to add Adblock in our chrome, and how to detect Adblock with the help of jQuery.

Also, check What Is Serilog In .NET Core?

Submit a Comment

Your email address will not be published. Required fields are marked *


Select Categories