You may not have come across the term ‘code bloat’ or ‘website bloat’ before so today we’re going to shed some light on what it is, why it is far from ideal (especially for your business website), and how to avoid it. Let’s start with a definition of what it actually means.
What is Code-bloat?
According to Wikipedia, ‘code bloat is the production of program code (source code or machine code) that is perceived as unnecessarily long, slow, or otherwise wasteful of resources.’ In layman’s terms, it means any sort of code that doesn’t need to be there or could be rewritten in a more efficient way.
Think of code as simply a language, just like English or Spanish for example, now consider that just like writing in one of these languages, there are sometimes many ways to say the same thing. Sometimes it is necessary to communicate with lots of words, paragraphs, sentences; other times it is better to say less and keep it short. This is just the same with the language of code.
Many times there are dozens of different ways to achieve exactly the same end result through coding, and it can come down to personal preference oftentimes as to how you choose to write it, though there are some coding best practices which are worth briefly mentioning.
4 Basic Coding Principles
1) DRY (Don’t Repeat Yourself)
When speaking or writing, it is often considered bad practise to repeat yourself over and over again. This is the same with coding. If you find yourself repeating the same code throughout, usually this is a sign that it is time to tidy the code up to avoid this.
2) KISS (Keep It Simple Stupid)
This means that the code that is written should be as simple as it possibly can be & that websites should try to avoid being overly complex all the time in their approach. This makes maintaining and supporting the website much easier in the months/years to come.
Code should be modular meaning, broken down into smaller, reusable chunks which goes hand in hand with our DRY approach above as well. Taking advantage of all the features within the code language such as functions, partials, etc.
A key part of programming is refactoring the code that is written the first time around. Oftentimes you will be able to tidy up some of that code to fit into one of the principles above whether it be, repeating yourself less, making it more simple, or reducing the chunks of code into smaller modules.
Why is code bloat a problem anyway?
It can be a big problem for (potential) customers visiting your website because of the amount of redundant code. All that code that isn’t needed, being loaded across multiple pages can drastically have an impact on site speeds and turn customers away from visiting your website. Not to mention the damage it can do to your SEO (Search Engine Optimisation) efforts.
Did you know: 47% of people expect a web page to load in two seconds or less?
The big culprits for this are often the off-the-shelf themes, or page builder plugins that try to be all things to all people. I wrote more about this here and what to look for with these off-the-shelf themes. Rather than a bespoke WordPress website which is tailored 100% to your business needs, these low cost page builders and themes try to cater for absolutely everyone, and they therefore throw the kitchen sink into them all of which weighs down the site and creates this ‘code bloat’.
I’d say 95% of the time, you’re never going to use even a fraction of the features they have packed in, and you’re probably just looking for a quick and easy way to get a new website online with somewhere to add content.
Sounds about right? Bespoke websites don’t need to cost the earth though, and I would always recommend consulting with a local web design company before purchasing anything, to get an expert opinion.
As well as being too slow, these culprit websites are usually too much of a headache for other developers to maintain and support, the code is a maze and it is like pulling at threads on a jumper knowing how it has all been put together.
My advice to you if you are considering a new website and want to avoid this dreaded code bloat, speak to one of our knowledgeable team here at Cariad or look at our portfolio of stunning websites to get some ideas for how to make your next website a success.