Notes from building a WordPress theme in 2017

WordPress

It’s been a good many years since I last put a WordPress theme together. I spent some time last weekend doing just that however, owing to the poor performance of WordPress’ default “Twenty Seventeen” theme which I had been using since switching back.

Over the course of the past 14 years, WordPress has grown to become the content management system of choice for a huge percentage of websites. With such a large reach, each decision has the potential to impact vast quantities of people, which is why I find the amount of stuff WP shoves into a webpage by default disturbing.

Indeed, the first thing I had to do on a clean WP install with a blank theme was explicitly turn off — at a theme level — a couple of jQuery libraries, an API endpoint, and an emoji library with an accompanying stylesheet. That’s not even the full list. This was the snippet needed in order to reach something that could actually be considered a blank slate:

/**
 * Remove a load of WP defaults
 */
remove_action('wp_head', 'rsd_link'); // EditURI link
remove_action('wp_head', 'wlwmanifest_link'); // Windows Live Writer
remove_action('wp_head', 'wp_generator'); // Version
remove_action('wp_head', 'print_emoji_detection_script', 7); // Emoji
remove_action('wp_print_styles', 'print_emoji_styles'); // Emoji
remove_action('rest_api_init', 'wp_oembed_register_route'); // REST API endpoint
remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10); // Don't filter oEmbed results
remove_action('wp_head', 'wp_oembed_add_discovery_links'); // Remove oEmbed discovery links
remove_action('wp_head', 'wp_oembed_add_host_js'); // Remove oEmbed-specific JavaScript
if (!is_admin()) {
  wp_deregister_script('jquery'); // jQuery
  wp_register_script('jquery', '', '', '', true); // jQuery
}

It’s not all doom and gloom though.

The tooling around WP was the most pleasant surprise for me. Whilst limited both in quantity and quality back in the day, the WordPress community has kept pace with the surge of tooling we’ve seen in other communities over recent years, resulting in many opportunities for a much improved workflow. Once set up, I actually found theming WordPress to be faster than theming Jekyll — gobsmacking to say the least.

The Roots team seem to be making the most interesting tooling around WP at the moment and this very site is built around Sage — their “WordPress starter theme with a modern development workflow”. I’d recommend it as a starting point for your next theme without a shadow of a doubt.

All in all I have no regrets about the move back to WordPress. I was slightly concerned about the performance I was getting with the default theme, even though I knew that coming back to database-driven land would incur a performance hit. With this new theme that doesn’t load all of WordPress’ default libraries and a caching plugin in place, the site’s getting a low-to-mid 90s performance grade depending on the page you test. Not bad at all for a database-driven site on a $5/month Linode box.

Thanks for reading! If you liked this post, you may like others archived in: WordPress.