Alter the CSS or JS array adding in DNS domain info.
Parameters
array $array: CSS or JS array.
string $type: CSS or JS.
2 calls to advagg_add_default_dns_lookups()
- advagg_get_css in ./
advagg.module - Returns a themed representation of all stylesheets to attach to the page.
- advagg_get_full_js in ./
advagg.module - Get full JS array.
File
-
./
advagg.module, line 6058
Code
function advagg_add_default_dns_lookups(array &$array, $type) {
// Skip if advagg is disabled.
if (!advagg_enabled()) {
return;
}
// Remove this return once CSS lookups are needed.
if ($type !== 'js') {
return;
}
// Add DNS information for some of the more popular modules.
foreach ($array as &$value) {
if (!is_string($value['data'])) {
continue;
}
// Google Ad Manager.
if (strpos($value['data'], '/google_service.') !== FALSE) {
if (!empty($value['dns_prefetch']) && is_string($value['dns_prefetch'])) {
$temp = $value['dns_prefetch'];
unset($value['dns_prefetch']);
$value['dns_prefetch'] = array(
$temp,
);
}
// Domains in the google_service.js file.
$value['dns_prefetch'][] = 'https://csi.gstatic.com';
$value['dns_prefetch'][] = 'https://pubads.g.doubleclick.net';
$value['dns_prefetch'][] = 'https://partner.googleadservices.com';
$value['dns_prefetch'][] = 'https://securepubads.g.doubleclick.net';
// Domains in the google_ads.js file.
$value['dns_prefetch'][] = 'https://pagead2.googlesyndication.com';
// Other domains that usually get hit.
$value['dns_prefetch'][] = 'https://cm.g.doubleclick.net';
$value['dns_prefetch'][] = 'https://tpc.googlesyndication.com';
}
// Google Analytics.
if (strpos($value['data'], 'GoogleAnalyticsObject') !== FALSE || strpos($value['data'], '.google-analytics.com/ga.js') !== FALSE) {
if (!empty($value['dns_prefetch']) && is_string($value['dns_prefetch'])) {
$temp = $value['dns_prefetch'];
unset($value['dns_prefetch']);
$value['dns_prefetch'] = array(
$temp,
);
}
if ($GLOBALS['is_https'] && strpos($value['data'], '.google-analytics.com/ga.js') !== FALSE) {
$value['dns_prefetch'][] = 'https://ssl.google-analytics.com';
}
else {
$value['dns_prefetch'][] = 'https://www.google-analytics.com';
}
$value['dns_prefetch'][] = 'https://stats.g.doubleclick.net';
}
}
}