0

called unnecessary js and css request

http://www.example.com/wp-content/plugins/includes/js/jquery.form.min.js

http://www.example.com/wp-content/plugins/includes/js/scripts.js

orignal it was

http://www.example.com/wp-content/plugins/contact-form-7/includes/js/jquery.form.min.js http://www.serpentcs.com/wp-content/plugins/contact-form-7/includes/js/scripts.js

this is happen after i written a function in function.php

// below function is used to deque script on certain page
function wpa_scripts() {
    // if this is not the contact page, remove the script
    if(!is_page('contact-us') ){
        wp_dequeue_script( 'contact-form-7' ); // only available onto contact-form-7
    }
    if(is_page( 'contact-us' ) || is_page('blog-serpent-consulting-service')){
        wp_dequeue_script( 'themepunchtools' );
        wp_dequeue_script( 'fancybox' );
        wp_dequeue_script( 'showbiz-jquery.themepunch.showbizpro.min' );
        wp_dequeue_script( 'prettyphoto-js' );      
        wp_dequeue_script( 'owl-js' );              
        wp_dequeue_script( 'revmin' );                      
    }
}
 //adjust priority to make sure this runs after the plugins add their scripts/styles
add_action( 'wp_print_scripts', 'wpa_scripts', 100 );

After i remove a function still calling a js and css file.

after change add_action( 'wp_print_scripts', 'wpa_scripts', 100 ); to add_action( 'wp_enqueue_scripts', 'wpa_scripts', 100 );

work's fine all pages but not in "contact-us" page

it's include below link

http://www.example.com/wp-content/plugins/includes/js/jquery.form.min.js

http://www.example.com/wp-content/plugins/includes/js/scripts.js

i need

http://www.example.com/wp-content/plugins/contact-form-7/includes/js/jquery.form.min.js http://www.serpentcs.com/wp-content/plugins/contact-form-7/includes/js/scripts.js

  • Apart from the wrong hook, you should dequeue and deregister to completely remove scripts and styles – Pieter Goosen Jun 17 '16 at 12:53
2

The hook to use is wp_enqueue_scripts instead of wp_print_scripts

  • i had done changes but in "contact-us" page include link is not perfect it's still add wrong link,as i metion in my question and in other page works fine. – user3234646 Jun 17 '16 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.