From ee8e173193182a94310bb8cdb067cc5cc4ec4d19 Mon Sep 17 00:00:00 2001 From: QWp6t Date: Sun, 26 Mar 2017 14:21:46 -0700 Subject: [PATCH] [jquery-cdn] Prefetch code.jquery.com --- modules/jquery-cdn.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/jquery-cdn.php b/modules/jquery-cdn.php index dcc24061..ef025365 100644 --- a/modules/jquery-cdn.php +++ b/modules/jquery-cdn.php @@ -21,6 +21,13 @@ function register_jquery() { true ); + add_filter('wp_resource_hints', function ($urls, $relation_type) { + if ($relation_type === 'dns-prefetch') { + $urls[] = 'code.jquery.com'; + } + return $urls; + }, 10, 2); + add_filter('script_loader_src', __NAMESPACE__ . '\\jquery_local_fallback', 10, 2); } add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\register_jquery', 100);