Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
[jquery-cdn] Prefetch code.jquery.com
Browse files Browse the repository at this point in the history
  • Loading branch information
QWp6t authored Mar 26, 2017
1 parent 9045500 commit ee8e173
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/jquery-cdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ee8e173

Please sign in to comment.