Instead of using external jquery hosted on google i would like to use a local copy. I am able to tell wp to use the local version, however, I seem to be unable to stop wp requesting the google hosted one. when I do (in functions.php):
`function register_local_juery() {
wp_deregister_script('jquery');
wp_enqueue_script('jquery', 'url/to/local/jquery', array(), null, true);
}
add_action('wp_enqueue_scripts', 'register_local_juery');`
The result of this is that wp includes both. The local and external. How can I stop wp from using the external source? In times of increasing awareness with privacy, shouldn't that be a kind of more obvious option? Is it possible that the call to googleapi is initiated by any plugin I have installed? Or do they always use the one registered with wp theme?
Instead of using external jquery hosted on google i would like to use a local copy. I am able to tell wp to use the local version, however, I seem to be unable to stop wp requesting the google hosted one. when I do (in functions.php):
`function register_local_juery() {
wp_deregister_script('jquery');
wp_enqueue_script('jquery', 'url/to/local/jquery', array(), null, true);
}
add_action('wp_enqueue_scripts', 'register_local_juery');`
The result of this is that wp includes both. The local and external. How can I stop wp from using the external source? In times of increasing awareness with privacy, shouldn't that be a kind of more obvious option? Is it possible that the call to googleapi is initiated by any plugin I have installed? Or do they always use the one registered with wp theme?
Share Improve this question edited Oct 3, 2019 at 7:22 Macs asked Oct 3, 2019 at 7:17 MacsMacs 32 bronze badges1 Answer
Reset to default 1WordPress doesn't use externally hosted jQuery. In fact, as far as I'm aware, WordPress core does not register any externally hosted scripts.
WordPress bundles its own version of jQuery, and you can enqueue the bundled version by just enqueueing the handle jquery
:
wp_enqueue_script( 'jquery' );
Or by specifying 'jquery'
as a dependency:
wp_enqueue_script( 'my-script', '/path/to/my-script.js', [ 'jquery' ] );
If you enqueue jQuery like that, but it's still loading an externally hosted version, then your theme or a plugin is either loading its own version separately, or has re-registered jquery
with an external version. The easiest way to find the culprit is to deactivate plugins, checking your site after each one, to see if the correct version is loading.