But! This is not the best solution. How to remove jQuery and jQuery migrate . Firstly, it’s not at all question when the engine loads something extra beyond your will.
And now we need to register our script. Add the following construction to the same functions.php file :
And secondly, the version that is being loaded now (jquery-1.12.4) does not work with some JS scripts.
For example, I was tired of messing with the "up" button on the site. I do not know why, but it was with this version that the button stubbornly refused not to work, but generally to be displayed. It works properly with other versions of jQuery library, even with older ones, but not with this one.
First you need to delete the script registered by the engine. To do this, add the following code in the functions.php file :
wp_deregister_script( 'jquery' );
And now we need to register our script. Add the following construction to the same functions.php file :
add_action( 'wp_enqueue_scripts', 'jquery_script_method' );
function jquery_script_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js', false, null, true );
wp_enqueue_script( 'jquery' );
}
At the same time, the latest version of jQuery 3.3.1 library will be downloaded from Google CDN.
If you want to download it yourself, then download the library file from the official jQuery website and add it to your template. The code in the functions.phpfile will need to be changed to the following:
add_action( 'wp_enqueue_scripts', 'jquery_script_method' );
function jquery_script_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', '/wp-content/themes/ваша_тема/js/jquery-3.3.1.min.js', false, null, true );
wp_enqueue_script( 'jquery' );
}
As you can see, only the link in the fourth line has changed. Here the path to the library and the word "your_theme" do not forget to replace with your own address and the name of your template:
Post a Comment