Deregister dequeue JS scripts except on 1 product page

Question

I need to deregister JS scripts everywhere except on one product page, so far this is my code:

add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
if ( !is_product('67688') ) {
wp_deregister_script( 'wc-lottery-jquery-plugin' );
wp_deregister_script( 'wc-lottery-countdown' );
wp_deregister_script( 'wc-lottery-countdown-language' );
wp_deregister_script( 'wc-lottery-public' );
}
}

Is this correct? Many thanks for your confirmation!

0
Fine Love Dolls 2 months 0 Answers 8 views 0

Leave an answer