How to completely disable JQuery in WordPress. Function code... open

How to completely disable JQuery in WordPress. Function code example

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators

If your WordPress template is written in pure JS and the installed plugins work correctly without the connected jQuery library, then you can disable it – thereby improving the site loading speed.

Be careful disabling can lead to errors in the functioning of the site, make sure that your active scripts are not written on jQuery

To disable add in your theme function.php file code below:

function replace_jquery() {
  if (!is_admin()) {
    wp_deregister_script('jquery');
    wp_register_script('jquery', 'https://code.jquery.com/jquery-3.6.0.min.js', array(), null, true);
    wp_enqueue_script('jquery');
  }
}
add_action('wp_enqueue_scripts', 'replace_jquery');
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation