WordPress shields jQuery files loaded by themes or plug-ins

Source: Internet
Author: User
Tags jquery library


Disable loading the default jQuery library.

Function my_enqueue_scripts () {wp_deregister_script ('jquery ');} add_action ('WP _ enqueue_scripts', 'My _ enqueue_scripts ', 1 );

This code directly prohibits the introduction of jQuery plug-ins, but is also disabled in the background, which may affect the functions of the background.

Selectively load jQuery

If (! Is_admin () {// function my_init_method () {wp_deregister_script ('jquery ') is not prohibited in the background; // cancel the original jquery definition} add_action ('init ', 'My _ init_method ');} wp_deregister_script ('l10n ');

The above method first checks whether it is in the background, then removes the definition of the jQuery file, mounts it to the init filter of WordPress, and adds the above code to the functions file of the current topic.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.