5 Ways to Cut Out Heavy Code on Your WordPress Site
The following post is a guest post by Paul Lentz from ShareThis.
Your site can be beautifully designed and filled with top-notch content. But if it's weighted down by heavy code, people won't get to enjoy the great experience you've created for them.
That's why you want to be sure your WordPress site is a lean, mean, properly coded machine.
According to GTmetrix, a popular tool for determining site performance, inefficient code is a key cause of slow website speeds. If you don't clean up your code, you could leave visitors frustrated and left to abandon your site for a faster one.
In fact, research from Akamai found that 40% of people abandon a site if it takes longer than three seconds to load. And 47% of people expect a page to load in two seconds or less. Site speed is also important for your search ranking, as this is one of Google's main factors in identifying user-friendly sites.
You can use tools like Google's PageSpeed Insights, WordPress Speed Test, and Pingdom to check your website's speed. And if you find that certain elements of your site are slowing down your loading times, then you know it's time to take action.
Here are five ways to cut out heavy code on your WordPress site.
1. Minify JSS and CS files
“Minify" is just a funny term for shrinking. It allows you to cut the fat from your JSS and CS files. For example, minifying can remove whitespace, line breaks, comments, and new line characters from your code — anything that might be redundant or unnecessary. These elements might have been added by a developer who's trying to make her code easy to read. But for your server, they only slow down the process.
You don't have to be a programmer to do this, either. You can simply use WordPress SEO plugins like Autoptimize, WP Rocket, and W3 Total Cache to minify your code.
2. Choose a lightweight theme
Don't judge a theme by its cover. After all, some beautiful and flashy themes are full of heavy and unnecessary code. That's why it's important to make sure your theme's code can handle fast speed and optimizations.
To ensure that your site won't be slowed down by your framework, it's best to use WordPress' default, lightweight themes. For instance, Twenty Fifteen and Genesis by StudioPress are popular choices.
Remember that you can always add plugins later to customize your site and make it more appealing. But if you start out with a poorly-coded theme, it's hard to scale back, and your site will suffer slow loading times and risk losing customers. 40% of consumers will abandon a website that takes more than 3 seconds to load!
Related reading: 58 Spooky Statistics for Websites [Infographic]
3. Disable pingbacks
Pingbacks notify you when someone else has linked to your post on another website. These notifications will be posted in your comment sections by default, eating up space and code.
The good news is that it's easy to disable pingbacks on your posts going forward by clicking the option under the “Discussion" section of your settings. To disable pingbacks on older posts, use the Bulk Edit Post feature and choose “Do Not Allow" for pings.
These adjustments won't break the links you've earned on other sites; they'll just remove the notifications. And if you want to keep tabs on these mentions, you can always use tools like Google Alerts. There's no need to weigh down your site in the process.
4. Get rid of superfluous plugins
It's easy to get plugin-happy when building your WordPress site. There are so many options for plugins that can improve the user experience and even the management process. But if you keep enabling plugins, before you know it, your site will be overwhelmed with tons of extra code to carry.
That's why it's important to only choose plugins that are lightweight. The ShareThis plugin for WordPress, for example, is lightning-fast, customizable, and mobile-optimized.
It's also important to audit your plugins and make sure that each one is serving a crucial purpose. In fact, there's a plugin for that! The P3 Profiler will find plugins that slow down your site's loading time. And the Plugin Organizer can help you enable plugins only on certain pages so they won't bog down the rest of your site.
5. Limit post revisions
WordPress automatically saves revisions while you're writing content for your site pages. And that's great! It helps ensure that you never lose your work. However, it also means that your database can quickly fill up with revisions that no one needs anymore.
The solution is simple. Use the Revision Control plugin to set a cap on how many revisions are saved; two or three is a good start. Or you can add this short line of code to your wp-config.php file:
define( 'WP_POST_REVISIONS', 4 );
Adjust the number based on how many revisions you want WordPress to save.
Building a lightweight and lightning-fast site
WordPress code is a double-edged sword: You need it to run your site, but the more you have, the slower that site will run.
That's why it's crucial to be smart about the framework and backend of your site: Pick a theme that's not full of flashy widgets, cut back on post revisions, and choose only the plugins that really matter.
These are just a few small steps you can take right now to keep your site running smoothly and your visitors engaged.
For a full in-depth read on speeding up your WordPress site, checkout our full post guide on site speed optimization. To offer clients secure, light-ning fast WordPress sites hoste don the Google Cloud platform, checkout Vendasta's Website Pro!
Read more from WebTober:
- Web Content 101: Why Ugly Websites Finish Last
- How to Sell Website Services to Local Businesses
- Noob-Friendly 10-Step Guide to Creating Small Business Websites
- No Devs Necessary: Why You Need a White Label Website Builder
- Speed Kills: How to Audit and Improve Your Website’s Speed and Performance