You are here

private function JsOptimizer::testForGoogleAnalytics 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::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;
}