Removing WordPress plugin styles and scripts from the
I love WordPress plugins. In fact, I love them so much that on one of the websites I’m currently working on I have 26 plugins activated and more will be added in the foreseeable future.
One downside of plugins however is that a lot of them come with CSS and JavaScript, which have to be incorporated into the theme at some point to get the plugins to work. This often means an extra request for a .css file and/or .js file is added to the theme’s <head> tag. This, of course, is bad practice: you should try to make as little HTTP requests as possible to keep your site up to speed, put your javascript in the bottom of the page to ensure faster rendering, and it also gets real tough to maintain all those separate files if many things have to change (like styling the plugin’s elements).
Gladly, WordPress offers ways of disabling the CSS and JS files that are added by these plugins. I’ll elaborate on how the adding and removing of both works. If you already know or don’t care and just want the script, just jump to the final code now. Let’s take styles for example, and look at how these are disabled. (more…)