Have the browser prefech this domain to open the connection.

Paramètres

array $js: JS array.

1 call to advagg_mod_prefetch_link()
advagg_mod_js_post_alter dans advagg_mod/advagg_mod.module
Alter the js array.

Fichier

advagg_mod/advagg_mod.module, line 1988

Code

function advagg_mod_prefetch_link(array &$js) {
    if (!variable_get('advagg_mod_prefetch', ADVAGG_MOD_PREFETCH)) {
        return;
    }
    foreach ($js as &$values) {
        if (!isset($values['dns_prefetch'])) {
            continue;
        }
        foreach ($values['dns_prefetch'] as &$url) {
            // Prefetch stats.g.doubleclick.net domain.
            if (strpos($url, '//stats.g.doubleclick.net') === FALSE) {
                continue;
            }
            if (variable_get('advagg_resource_hints_preconnect', ADVAGG_RESOURCE_HINTS_PRECONNECT)) {
                $parse = @parse_url($url);
                $inline_script = 'var preconnect_support = false; try {if (document.createElement("link").relList.supports("preconnect")) {preconnect_support = true;}} catch (e) {} if (!preconnect_support) { var prefetch = document.createElement("link"); prefetch.href = "https://' . $parse['host'] . '/robots.txt"; prefetch.rel="prefetch"; document.getElementsByTagName("head")[0].appendChild(prefetch);}';
                $js['advagg_preconnect_support'] = array(
                    'type' => 'inline',
                    'group' => JS_LIBRARY - 1,
                    'weight' => -50000,
                    'scope_lock' => TRUE,
                    'movable' => FALSE,
                    'no_defer' => TRUE,
                    'data' => $inline_script,
                ) + drupal_js_defaults($inline_script);
            }
            else {
                $url .= '#prefetch';
            }
        }
    }
}