Skip to content

Instantly share code, notes, and snippets.

@marklchaves
Last active September 27, 2020 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marklchaves/48666eecdc5af5007f5913e4ac7f23e1 to your computer and use it in GitHub Desktop.
Save marklchaves/48666eecdc5af5007f5913e4ac7f23e1 to your computer and use it in GitHub Desktop.
PHP code to prevent loading of Revolution Slider and Contact Form 7. Test the Rev Slider code. I recall having trouble deregistering Themepunch.
<?php
/**
* Don't load Revolution Slider & Contact Form 7 plugins
* if the page doesn't need them.
*/
function my_deregister_javascript() {
if ( !is_page(YOURPAGEGOESHERE) ) {
wp_deregister_script( 'jquery.themepunch.tools' );
wp_dequeue_script( 'jquery.themepunch.tools' );
wp_deregister_script( 'jquery.themepunch.revolution' );
wp_dequeue_script( 'jquery.themepunch.revolution' );
}
if ( !is_page(YOURPAGEGOESHERE) ) {
wp_deregister_script( 'contact-form-7' );
wp_dequeue_script( 'contact-form-7' );
wp_deregister_script( 'avada-contact-form-7' );
wp_dequeue_script( 'avada-contact-form-7' );
}
}
add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
/**
* Really make sure the Revolution Slider JS don't load
* if the above does not work.
*/
function wra_remove_wphead_filter(){
if ( !is_page(YOURPAGEGOESHERE) ) {
remove_action('wp_head', 'jquery.themepunch.tools', 10);
remove_action('wp_head', 'jquery.themepunch.revolution', 10);
}
}
add_action('wp_print_head_scripts', 'wra_remove_wphead_filter', 100000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment