Disclosure: Some of the links in this post are “affiliate links.” This means if you click on the link and purchase the item, I will receive affiliate commission.
This is more for WordPress theme developers than it is for, plugin developers but the concept is the same. Themes and plugins in WordPress suck at loading their assets. This is for both; the frontend and the backend (wp-admin). There are many reasons for this. Either to maintain compatibility with strange implementations for plugins and new features. Or it could be out of pure laziness. However, I want to start by addressing an example.
You may be quick to point out that if it is already cached then it won’t impact your load time. This is also the time where I start to get annoyed. It is a very poor argument to suggest that we should load everything on every page because it can be cached. In fact, Google’s Lighthouse has expanded it’s recommendation in a recent update to “remove unused CSS rules.” Albeit, this has a minor impact on performance. However, it begins to hit home on the issue with modern website design and optimization.
Modern Design & Optimization Focuses On Number’s Not What’s Being Served
When aggregating your CSS files and the media type of the file that matches your current device, the browser will download and evaluate all of the CSS used or unused. This is done to determine what needs to be used to pain the website and what doesn’t. Therefore, adding all of these plugins might add 50kb to the size of your total compressed CSS, but when you look at the uncompressed versions, you will realize that the browser still has to evaluate all of that CSS. The issue is also glaringly apparent when optimizing for mobile devices.
As A Website Owner, What Can You Do?
We have written tutorials for removing assets for various plugins, including BuddyPress which can be found here. By removing these assets, you’ll see a major improvement in your website’s performance. It will reduce the amount of time it takes for a browser to render and display your website.
More importantly, you can tell your theme and plugins about the issue and have them fix it. For example, there is a popular theme called Newspaper on ThemeForest. This theme was loading their CSS for bbPress and WooCommerce in their own files, but not BuddPress. I reached out to the theme developers and pointed out that adding it to the main theme styles would lead to several issues. The developer’s agreed and are rectifying the issue in another release.
As A Developer What Can You Do?
I’m not asking every developer to set strict rules and break thousands of websites that use their plugins. That being said, there should be a setting in your options panel that will load the assets more intelligently. By using this method, the end user will become more aware of the issue and theme developers will likely conform to more standard use cases of your plugin.
Obviously, not all plugins can do this. However, it would be a step in the right direction. Let’s contribute to making the web a faster and less bloated place.