I am using following code to add some scripts in WP pages like
function add_js() {
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", false, null);
wp_enqueue_script('jquery');
wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() .'/js/bootstrap.min.js', array('jquery'),'',true );
wp_enqueue_script( 'colorbox-js', get_template_directory_uri() .'/js/jquery.colorbox-min.js', array('jquery'),'',true );
wp_enqueue_script( 'img-loader', get_template_directory_uri() .'/js/img-load.js', array('jquery'),'',true );
wp_enqueue_script( 'box-tanzim', get_template_directory_uri() .'/js/tanzim.js', array('jquery'),'',true );
wp_enqueue_script( 'scripts-js', get_template_directory_uri() .'/js/scripts.js', array('jquery'),'',true );
}
add_action( 'wp_enqueue_scripts', 'add_js' );
but I don’t want to add unnecessary scripts on some pages! for example I would like to have all of above scripts on front-page.php
but on other pages I don’t need last three scripts.
Can you please let me know how I can filter them?
Thanks
something like this maybe