Code
Superfluous code
Superfluous code is code that’s poorly optimised. It’s extra code that doesn’t add meaningful value, functionality, or substance to your site. If you were to remove it, you’ll need take extra consideration of what might break.
Examples of this code include an excess of:
- Visual animations
- Tracking pixels and monitoring tools
- Chatbots
- Widgets
If too many of these things are coded into your website and work simultaneously, it can hamper performance and create a slow experience for your visitors.
Poorly structured code
Bad code equals bad performance. Poorly structured code increases page load times and leads to an inferior user experience. Weak code like invalid HTML markup, JavaScript errors, or resource-hungry processes can cause significant dips in performance if left unmanaged.
“Remember: everything you add to your website has a performance cost.”
Mike Thomas,
Technical Director, Blend
Consider a performance budget
Everything you add to a website has a performance cost. To ensure you don’t add too many extra elements to yours, it’s important to embrace performance budgets.
A performance budget is a clearly-defined limit for pages that your development team can’t exceed. This can be a max JavaScript bundle size, total image weight, or a strict limit on loads speeds.
Having a pre-set budget in place helps you to plan ahead and make better decisions about what can and can’t be included on your site. It also creates a culture of accountability that enables you to weigh the impact to user-centric metrics of each change to a site.
Keep track of extra code additions
If you add extra code like tracking pixels or analytic tools, you need to regularly review their usage. We recommend setting periodic reminders to check if they’re still providing useful insights and removing them if they’re no longer required.
If you continually review your code additions, you’ll have a better idea of what’s working and what isn’t, so you can optimise performance.
Work with an agency with broad technical expertise
To ensure that your code is well-structured with no superfluous additions, we recommend working with an agency with broad technical expertise. They’ll be able to create your website in the most efficient way possible and make performance a priority.
The CMS/ hosting platform
Traditional website development is built upon a code-based framework like WordPress or Concrete5. This approach requires hosting arrangements to provide the core CMS functionality, which in today’s world is a specialised area.
Hosting your own website is often expensive, time-consuming, and technically demanding. If your hosting is inadequate, your performance can take a hit. Single instance servers often struggle to meet demand. And if you lack load balancing or content delivery networks, your users might struggle to access your site.
Platform as a Service providers like HubSpot mitigate this hassle by managing it all for you in modern, distributed platforms. As they do this at scale, they have access to the experts required to make sure things are globally performant, secure, and accredited.
The HubSpot CMS is especially useful, as its commercially developed and maintained. This means that all feature development is controlled by HubSpot, which makes the CMS more reliable and secure than other alternatives. Plus, they have a suite of inbuilt performance tools on their platform, like automated image optimisation, code minification, free SSL certificates, and more.
“Where possible, don’t host your own website.”
Mike Thomas,
Technical Director, Blend
Image and file size
When planning the design of your website, remember that large graphics and photos can have a sizeable impact on page load times. If you employ lots of high-resolution images, you can also negatively impact Core Web Vitals, which can affect your Google ranking.
It’s important to find a balance between pages that need more impact, and those that require optimum performance. For example, your landing pages that host important CTAs will need to load fast and be as smooth as possible.
First, make sure that you’re not overusing images across your site. Think of each as another resource that needs loading and choose them intentionally. Next, you’ll need to resize your images to the desired dimensions. If you rely on your browser or server to do this, it’ll eat up extra time and hamper performance. So it’s better to do this yourself before uploading. Lastly, keep your files as small as possible. We recommend using a compression tool to reduce files so they’re small enough to improve performance but large enough to retain quality.
Recommended file types:
- Photos best as JPG or WebP
- Solid blocks of colour are best suited to PNG
- Less complex versions of the above can be used as SVG
HTTP requests
Every website uses the Hypertext Transfer Protocol (HTTP). For a website to load in a web browser, the browser must first send an HTTP request to the website’s hosting server. The server then sends back the requested resource. Each resource request decreases load speed, so the fewer requests you have, the better your site will perform.
For the best performance, ensure your hosting provider can deliver content over HTTP2. HTTP2 is the modern equivalent of HTTP1 and is much faster and more reliable. It also has built-in multiplexing, so it can load more requests in parallel with each other. This helps to overcome lag issues that can crop up.
You should also ask your developers to combine, minify and deliver CSS/JS with effective caching policies. This helps reduce the number of HTTP requests and ensures that a users’ browser only fetches the resource when required.
Each image, script and stylesheet are submitted as a single HTTP request. A simple tracking code may well load dozens of additional requests, so review them regularly.
Browser caching
Caching is the process of storing data in a place where it can be easily accessed at a later date. A browser cache saves website data like HTML files and images on the visitors’ device. When they return to the web page, the browser loads these files from its local cache instead of requesting them from the web server, which is faster and uses less bandwidth.
With an effective caching policy, you can:
- Reduce page load times for repeat visitors
- Speed up subsequent page visits
- Use less bandwidth
This process is essential for static web content that sits on your website for long periods. Content like global CSS styles and logos can be safely stored for a year before refreshing. Everything else on your site that changes on a more regular basis should be stored for no longer than a week. Check with your developer that the “Cache-Control” and “Expires” headers are correctly set. This will ensure that your caching policy is working correctly.
Content delivery networks
The larger the distance between the device making HTTP requests and your servers completing the requests, the longer your website files will take to send and load.
You can remedy this problem with a content delivery network (CDN). A CDN is a collection of servers distributed around the world that hold cached copies of your website files. When a user visits your website, your CDN will determine the server closest to their physical location and deliver the files from that server.
CDNs are a great way to help distribute your static assets across geographic regions – effectively bringing the files closer to your users. This can be particularly useful if your website itself isn’t load-balanced across multiple regions and can help you boost performance considerably.
Mobile optimisation
A growing number of people use mobile devices as their primary method of accessing web content. In the first quarter of 2021, mobile devices generated 54.8 percent of global website traffic. Even with such a high proportion of users preferring mobile, it can be easy for designers and developers to forget this and overlook them in favour of desktop devices.
To ensure a great experience and consistent performance for all users, you need to take a mobile-first approach to your website. Responsive web development is key, and it’s easier to do this at the start of a new project.
We recommend using Google Analytics to identify what devices your visitors use. If more users are on mobile, then make a mobile-first strategy a priority. This locks in a high-performance approach from the offset, allowing you to selectively introduce more expensive enhancements for larger devices, rather than introduce them later down the line.
Use plugins sparingly
Liberal use of WordPress and other marketplace plugins can be a tempting option for you and your developers. But while they might look like a shortcut to advanced functionality, they’re not always created with performance in mind.
The bar for entry is low, so the quality often varies wildly between plugins. Plus, they can introduce lots of new coding elements like tracking or analytics to your website. Many of these plugins use similar code, so you could be introducing superfluous code into your system without gaining any extra benefits. Use these plugins sparingly as they can hamper performance, slow down your site, and decrease performance.