This is a followup to my previous post on adding scripts only to the WordPress pages that need them. Please read that first, or this might not make much sense…
To cleanup the dynamically generated head section even more, you can disable the styles associated with scripts that aren’t loaded on every page.
The easy way to do this is very similar to what I talked about last time – add this code to your functions.php file (or custom-functions.php if your theme supports it):