> ## Documentation Index
> Fetch the complete documentation index at: https://docs.domshot.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Ad Blocking

> Block ads in screenshots

## Ad Blocking

Block advertisements from appearing in your screenshots using built-in ad blocking technology.

## How it works

When enabled, the blocker intercepts network requests and blocks known ad servers and tracking scripts before they load.

## Basic usage

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&blockAds=true" \
    --output screenshot.png
  ```

  ```typescript typescript theme={null}
  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    blockAds: 'true'
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('screenshot.png', blob));
  ```

  ```php php theme={null}
  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'blockAds' => 'true'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('screenshot.png', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "net/http"
      "net/url"
  )

  func main() {
      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")
      params.Set("blockAds", "true")

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

## Benefits

* **Cleaner screenshots** - Remove distracting advertisements
* **Faster loading** - Fewer resources to download
* **Consistent results** - Avoid dynamic ad content variations
* **Privacy-focused** - Blocks known tracking scripts

<Warning>
  Ad blocking may cause layout shifts or broken elements on websites that rely heavily on ad revenue. Test thoroughly before using in production.
</Warning>

## When to use ad blocking

| Use case                  | Recommended                  |
| ------------------------- | ---------------------------- |
| Documentation screenshots | Yes - cleaner appearance     |
| E-commerce sites          | Maybe - may affect layout    |
| News sites                | Yes - removes ads/clutter    |
| Social media              | Yes - improves consistency   |
| Testing web apps          | No - may break functionality |

## Combining with other blocking

Ad blocking can be combined with banner and tracking blocking:

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&blockAds=true&blockBanners=true&blockTracking=true" \
    --output screenshot.png
  ```

  ```typescript typescript theme={null}
  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    blockAds: 'true',
    blockBanners: 'true',
    blockTracking: 'true'
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('screenshot.png', blob));
  ```

  ```php php theme={null}
  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'blockAds' => 'true',
    'blockBanners' => 'true',
    'blockTracking' => 'true'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('screenshot.png', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "net/http"
      "net/url"
  )

  func main() {
      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")
      params.Set("blockAds", "true")
      params.Set("blockBanners", "true")
      params.Set("blockTracking", "true")

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

See also:

* [Tracking Blocking](/guides/content/tracking-blocking) - Block tracking scripts
* [Cookie Banner Blocking](/guides/content/cookie-blocking) - Block cookie consent banners

## Parameters

| Parameter  | Type    | Default | Description                               |
| ---------- | ------- | ------- | ----------------------------------------- |
| `blockAds` | boolean | `false` | Enable ad blocking using prebuilt filters |

## Performance impact

Ad blocking has minimal performance overhead:

* Initial filter loading: \~50-100ms (one-time per request)
* Network request blocking: Reduces overall page load time
* Memory usage: Slight increase for blocker instance

<Tip>
  For pages with heavy advertising, enabling ad blocking often results in faster screenshots and smaller file sizes.
</Tip>
