Skip to content

Instantly share code, notes, and snippets.

@fernandiez
Created August 2, 2017 10:13
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 fernandiez/aaad250e0ddc36d748a56418e9233c05 to your computer and use it in GitHub Desktop.
Save fernandiez/aaad250e0ddc36d748a56418e9233c05 to your computer and use it in GitHub Desktop.
Dequeue CSS Styles and JavaScript Scripts in child theme
// Dequeue CSS Styles and JavaScript Scripts in child theme
// Dequeue Styles
function dequeue_unnecessary_styles() {
wp_dequeue_style( 'bootstrap-map' );
wp_deregister_style( 'bootstrap-map' );
}
add_action( 'wp_print_styles', 'dequeue_unnecessary_styles' );
// Dequeue JavaScripts
function dequeue_unnecessary_scripts() {
wp_dequeue_script( 'modernizr-js' );
wp_deregister_script( 'modernizr-js' );
wp_dequeue_script( 'project-js' );
wp_deregister_script( 'project-js' );
}
add_action( 'wp_print_scripts', 'project_dequeue_unnecessary_scripts' );
@fdunnington
Copy link

I'm trying to dequeue Modenizr on this site as it seems to be slowing it down quite a lot, and I don't think it's necessary, but I can't work out how to do it. I've tried deleting the contents of the JS file, and deleting the contents of the plugin.js file that calls the script, but it's still being called, so I'm obviously missing something.

It's probably a really stupid mistake I'm making as I'm pretty new to all this, but any ideas would be welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment