Weblog Tools Collection: How To Include CSS and JavaScript Conditionally

This post written on the forums as a news submission has been well received by plugin developers that have taken notice. The article explains how to include CSS and JavaScript conditionally so that the code is not loaded on every page of the site.

If you think about it, there are many plugins that only do something once in a blue moon. Table of contents, text manipulators, galleries, sliders, etc, etc. If only they loaded their frontend code strictly when necessary, most page loads would suddenly become much lighter.

This technique if implemented by plugin authors sounds like it could have a significant impact on end users websites, especially when it comes to loading times. I’m always impressed with the speed of WordPress when I install a fresh copy without any plugins. WordPress loads very quickly both on the front and back ends. However, once I activate 30 or so plugins, most of which add functionality to the front end of the site, I see the page loads increase significantly. It’s a shame too since I routinely hear people claim WordPress is sluggish software only to find out they have over 30 plugins activated on their site.

If you’re a plugin author, can you please tell me what some of the drawbacks are with Artems approach?

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.