January 30, 2016

Beware the Bloat of Stock WordPress Themes

Disclaimer: I imported this post from WordPress to Jekyll on 9/2/23. Forgive the misformatting until I get a chance to clean it up.

Theme Bloat

When spinning up a cheap budget WordPress site, it is common and far more affordable to purchase a stock premium WordPress theme from a marketplace like Themeforest than to build a custom theme. The quality of these themes vary widely; but, with adequate research, I have been able to find pretty solid themes for not a lot of money over the years. The theme this site used to run, Readme, is a phenomenal, lightweight theme that still packs a good number of features. Furthermore, their ongoing support has been excellent.

Any theme made for the broad market has features that not everyone will use. Readme, for example, includes a lot of jQuery and CSS files for interesting features; however, I am choosing not to use many of them at this time. Even though a theme does not use the features, is still instructs WordPress to load up all these extra files to my clients increasing page load time and wasting bandwidth.

Eliminating the Bloat

So, by stepping through each .js and .css file loaded, I determined which files I needed for the current feature set that I am using and eliminated the rest. Deregistering unneeded scripts and styles is relatively simple, assuming you have a child theme setup already. For example, in the snippet below I remove the share button feature by deregistering its script and style in my child theme’s functions.php.

function remove_scripts()
wp_deregister_script( 'selection-sharer' );
wp_deregister_style( 'selection-sharer' );
add_action( 'wp_enqueue_scripts', 'remove_scripts', 100 );

After eliminating this batch of CSS and jQuery plugins, I do see some moderate improvements. It does not work magic, but why load that extra ~100kb of data and process an additional seven server requests when they are not needed at all? If you are running a WordPress stock theme and looking to get an extra ounce of performance, I recommend trying this out.

[![Pingdom Test Before Removing Bloat](/assets/img/readmeBefore_cb-248x300.jpg)](/assets/img/readmeBefore_cb.jpg)
**Fig. 1.** Pingdom Test Before Removing Bloat
[![Pingdom Test After Removing Bloat](/assets/img/readmeAfter_cb-252x300.jpg)](/assets/img/readmeAfter_cb.jpg)
**Fig. 2.** Pingdom Test After Removing Bloat