You are here

private function JsOptimizer::testForGoogleAdManager in Advanced CSS/JS Aggregation 8.4

Same name and namespace in other branches
  1. 8.3 src/Asset/JsOptimizer.php \Drupal\advagg\Asset\JsOptimizer::testForGoogleAdManager()

Test if the provided path is from Google Ad Manager and add DNS entries.

Parameters

string $path: The path to check.

Return value

array Array of prefetch domains if file is from Google Ad Manager.

1 call to JsOptimizer::testForGoogleAdManager()
JsOptimizer::addDnsPrefetch in src/Asset/JsOptimizer.php
Extract any domains to prefetch DNS.

File

src/Asset/JsOptimizer.php, line 81

Class

JsOptimizer
The JavaScript Optimizer.

Namespace

Drupal\advagg\Asset

Code

private function testForGoogleAdManager($path) {
  $prefetch = [];
  if (strpos($path, '/google_service.') == FALSE) {
    return $prefetch;
  }

  // Domains in the google_service.js file.
  $prefetch[] = 'https://csi.gstatic.com';
  $prefetch[] = 'https://pubads.g.doubleclick.net';
  $prefetch[] = 'https://partner.googleadservices.com';
  $prefetch[] = 'https://securepubads.g.doubleclick.net';

  // Domains in the google_ads.js file.
  $prefetch[] = 'https://pagead2.googlesyndication.com';

  // Other domains that usually get hit.
  $prefetch[] = 'https://cm.g.doubleclick.net';
  $prefetch[] = 'https://tpc.googlesyndication.com';
  return $prefetch;
}