Disable Javascript on Specific Page/Post

With this code you can disable (unnecessary) script or JS files (plugin) on specific page or post to reducing https request and can increase speed of your WordPress site before page or post loads.

HOW TO:
1. Open main .php and search wp_enqueue_script or script file name
2. Open your theme’s functions.php file
3. Copy, Paste and Edit code below and click Update File
EXAMPLE:
In this example, we’re disabling or loading Javascript file Contact Form 7 (‘contact-form-7‘) except in selected page or post (e.g. Contact)

add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
 
function my_deregister_javascript() {
   if ( !is_page('Contact') ) {
    wp_deregister_script( 'contact-form-7' );
     }
}

1. Disabling Javascript on Page

Edit Home or page and javascript-name-file according your JS files

add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
 
function my_deregister_javascript() {
   if ( !is_page('Home') ) {
    wp_deregister_script( 'javascript-name-file' );
     }
}

2. Disabling Javascript on Post

For post using post id (e.g. ‘1‘) and javascript-name-file according your JS files

add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
 
function my_deregister_javascript() {
   if ( !is_single('1') ) {
    wp_deregister_script( 'javascript-name-file' );
     }
}

Once Updated File, the script will (deregister) no longer load except the page or post specify.