Follow Brian Li (@DecryptoBL) on Twitter.
Follow Brian Li (@bwhli) on Instagram.

How to Reduce Network Requests in WordPress by Combining Images

March 10, 2019

Over the past few weeks, I’ve been working on optimizing this website by implementing Cloudflare full-page caching on certain pages, refactoring CSS, and reducing the number of requests per page load. Every page on Decrypto has a Twitter icon in the top left corner and an Instagram icon in the top right corner. Previously, the two icons were two separate PNG images. After a little Photoshop and CSS magic, I’ve cut that number in half. Now, both icons are displayed with the same PNG image.

Continue Reading →


Optimizing Decrypto’s WordPress Install

February 10, 2019

I’m obsessed with optimizing my websites for performance. In this post, I’ll share a few tips and tricks that I use to make sure Decrypto loads quickly. Before we get into the optimization tips, here are two examples of Decrypto’s load time–277 ms for a text-heavy page and 0.6s for an image-heavy page.

Continue Reading →


How to Replace Text in WordPress with functions.php

January 8, 2019

This snippet can be used in a WordPress theme’s functions.php file to dynamically replace text on a specific part of the page. This example replaces text strings in the_content and nowhere else.

function replace_text($text) {
	$text = str_replace('<hr>', '<hr class="hr-small">', $text);
	$text = str_replace('<hr />', '<hr class="hr-small">', $text);
	$text = str_replace('>^<', 'class="rs">^<', $text);
	$text = str_replace('<sup>', '<sup class="rs-sup">', $text);
	return $text;
}
add_filter('the_content', 'replace_text');

Redirect 7xx px wide images to full-size images in WordPress with NGINX

December 30, 2018

Recently. I noticed a bunch of 404 errors involving 700px and 768px wide images. These were “large” image sizes I used in previous WordPress themes. After doing a regex search and replace on my database to get rid of all instances of -7\d{2}x\d{3}, I added the following NGINX rule to redirect any potential external direct links to the images.

location ~* "^\/wp-content\/uploads\/(.*)(-7\d{2}x\d{3})(..{3})$"  {
   return 301 https://decrypto.net/wp-content/uploads/$1$3;
}



Questions?

Find me on Twitter, or send me an email.