Same name in other branches
  1. 6.0.x src/Asset/JsOptimizer.php \Drupal\advagg\Asset\JsOptimizer::testForGoogleAnalytics()
  2. 8.x-3.x src/Asset/JsOptimizer.php \Drupal\advagg\Asset\JsOptimizer::testForGoogleAnalytics()
  3. 8.x-4.x src/Asset/JsOptimizer.php \Drupal\advagg\Asset\JsOptimizer::testForGoogleAnalytics()

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

Parameters

string $path: The path to check.

Return value

array Empty array or an array to prefetch if file is from Google Analytics.

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

File

src/Asset/JsOptimizer.php, line 111

Class

JsOptimizer
The JavaScript Optimizer.

Namespace

Drupal\advagg\Asset

Code

private function testForGoogleAnalytics($path) {
    $prefetch = [];
    if (strpos($path, 'GoogleAnalytics') == FALSE && strpos($path, 'google-analytics') == FALSE) {
        return $prefetch;
    }
    $prefetch[] = 'https://ssl.google-analytics.com';
    $prefetch[] = 'https://stats.g.doubleclick.net';
    return $prefetch;
}