• Hi, i need jquery for certain functionalities on my website e.g. https://www.apis.de/software/produkte/ to open the accordions. but i don’t need it on the main page: https://www.apis.de
    I have this code in my ‘header.php’ file : <?php wp_enqueue_script(“jquery”); ?>
    but i noticed that my page runs much quicker without it and i don’t need it for this page.
    Can you advise the best way to disable jquery on certain pages?
    thx in advance.

Viewing 1 replies (of 1 total)
  • add_action( 'wp_enqueue_scripts', 'my_deregister_scripts', 100 );
    
    function my_deregister_scripts() {
       if ( is_page('your_page') ) {
        wp_deregister_script( 'jQuery' );
    
         }
    }

    or simply do the opposite, frame the function you mentionned with a negative condition, it will be cleaner than enqueue and desenqueue a script :

    if ( !is_page('front-page') ) {
        wp_register_script( 'jQuery' );
    }
Viewing 1 replies (of 1 total)
  • The topic ‘disable jqeury on certain pages’ is closed to new replies.