I use some "heavy duty" plugging, like syntaxhighlighter, GD star rating etc. i create a de-register.php file which i use to deregister scripts and styles whenever they are not used.
Example:
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
function my_deregister_styles() {
if (is_home()) {
wp_deregister_style('bbp-default');
wp_dequeue_style('bbp-default');
wp_deregister_style('bbp-default-rtl');
wp_dequeue_style('bbp-default-rtl');
wp_deregister_style('edd-styles');
wp_dequeue_style('edd-styles');
wp_deregister_style('onp-sociallocker');
wp_dequeue_style('onp-sociallocker');
}
}
In this page i have about 200 lines since i am de-registering the css and js files of 5 plugins (or so) when ever they are not being used.
For that end i created some checkbox metaboxes in each post where i can click and say "i use rating here" (for example).
My question is.
Is my way wrong? Does the whole process of using wp_deregister_style and wp_deregister_script defeats the purpose?
Does the actual use of those actions slows my site down? Is there a better way to only use plugins and the styles and scripts they come with when i need them and only then?
I have of course read and searched but couldn't find anything else.
Would love to hear of any solution you think might fit.