Created
May 7, 2013 12:56
-
-
Save shrwnsan/5532340 to your computer and use it in GitHub Desktop.
WordPress: Selectively load plugins' styles/JS only for pages/views that needs them
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_deregister_styles() { | |
if (!is_page('Contact')) { | |
wp_deregister_style('contact-form-7'); | |
} | |
if (!is_single()) { | |
wp_deregister_style('tfg_style'); | |
} | |
} | |
function my_deregister_javascript() { | |
if (!is_page('Contact')) { | |
wp_deregister_script('contact-form-7'); | |
} | |
if (!is_single()) { | |
wp_deregister_script('tfg_script'); | |
} | |
} | |
add_action('wp_print_styles', 'my_deregister_styles', 100); | |
add_action('wp_print_scripts', 'my_deregister_javascript', 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment