learn

Website Performance Optimization Techniques

Website performance optimization is the process of making changes so your website seems faster to visitors. It includes everything that improves perceived website responsiveness—from JavaScript optimizations to faster response load time. Slow speed discourages visitors, increasing your website bounce rate and affecting search engine rankings.

According to Google, 53% of visitors leave if a mobile site takes longer than 3 seconds to load. Google PageSpeed Insights (PSI) reports on the user experience of a page on both mobile and desktop devices and provides suggestions on how that page may be improved. A score of 90+ is considered good for optimal search engine rankings.

This article examines the various factors impacting website performance and presents website performance optimization techniques to boost your website speed for better user experience and search engine rankings.

Factors impacting website performance

Before we review the techniques for optimizing your website, let’s examine a quick summary of the various factors that impact user experience:

Factor Impact
Image and file size The larger the files and the more images you have to load on a page, the longer it will take to load in a browser. 
Number of files If the page contains many different files, the total data transferred by the browser increases, resulting in slow loads.
File types Some file types require third-party software to open and can impact performance.
Hosting service Using a poor or shared hosting service can increase the initial server response time, which in turn increases your website's load time.
Software code Poorly structured or unused code can significantly affect performance. Uncompressed Javascript or CSS files are common issues.
Plugins Many plugins can help add extra functionality to your website, but overusing plugins increases your website’s load time.
Traffic volume A burst in traffic to your website can lead to a slowdown if the amount of network bandwidth provisioned by your hosting provider is insufficient.
Browser compatibility Different browsers interpret and render website code differently, leading to variations in performance and functionality.
Network latency The transaction path between the user and your website traverses multiple internet hosting providers. A slowdown anywhere in the path can result in a slowdown in user experience. 

Several other factors will affect your website but aren’t listed here. The best way to identify these factors and their impact on your website speed is by conducting a site test using a tool like WebPageTest .

We will refer to Core Web Vital signals like the Largest Contentful Paint (LCP) or First Contentful Paint (FCP) in this article. If you are unfamiliar with these concepts, you can learn them by reading this free guide.

A summary of key website performance optimization techniques

Once you’ve tested the speed of your website, it's time to optimize it. We summarize key techniques below.

Website performance optimization techniques Description
Use a content delivery network A CDN delivers content from a global network of caching nodes geographically closer to the end user locations, thereby reducing page load time.
Optimize website images Compress your images to reduce the size without losing the quality. You can also lazy load large images (explained later).
Optimize the website’s code Reduce resource consumption, and decrease execution in time.
Treat mobile users as first-class citizens Design a mobile-first website or consider a separate mobile-optimized version for your mobile users. You can also speed up the pages using AMP.
Improve the Largest Contentful Paint (LCP) score Optimize LCP, the largest image or text block visitors see when visiting your website.
Optimize website hosting The quality of your website’s hosting matters. Subscribe to a dedicated (vs shared) hosting service if your budget allows it.
Optimize your CMS database Tune your CMS (referring to your content management system, like WordPress) database queries to improve the server response time.
Avoid a preloader or animation Avoid a preloader on your website. It would block the First Contentful Paint (FCP), preventing the search engine from seeing your page and causing a poor user experience.
Mind the full transaction path to your website Factors beyond the front and back-end services, such as the domain name service (DNS) and Internet performance, affect the user experience

The rest of the article elaborates on the techniques mentioned above in detail.

#1 Use a content delivery network

A content delivery network (CDN) is a group of geographically distributed servers between your web server and end users. These servers store a copy of your content across various locations. When users visit your site, the CDN chooses a cache closest to their physical location to deliver content.

For example, if your website is hosted on a server in North America and users from India try to access it, the load time will be longer because the origin server is far from the user’s physical location. Instead, a CDN in India can deliver content much faster.

Apart from the page speed, here are some more benefits of using a CDN.

  • Security: CDN can route traffic through a secure system to protect sensitive data and information from malicious bots and users.
  • Reduce bandwidth: CDN serves cached content, meaning that the origin server doesn’t need to deliver the same content repeatedly, reducing the hosting cost.
  • Global reach: CDN allows you to deliver your content faster to international users who are geographically distant from your hosting provider’s servers.
  • DDoS protection: CDNs can protect against DDoS attacks by redirecting traffic to other servers instead of making the website unavailable.
  • Reduce cost: CDN reduces transit costs significantly, making global content delivery more affordable.
  • Traffic management: CDN handles traffic surges (as it sits between the user and the website hosting server), cutting down peak traffic loads on the origin server.

For example, if Cloudflare is installed on your website, you can try their advanced features to get the most out of their caching. Minify Javascript, CSS, and Cloudflare fonts are among the best features they provide. Here’s how to do it:

Click on Speed> Optimization under your Cloudflare Menu.

Click on the Content Optimization tab on the next screen.

After clicking on content optimization, you’ll see options like Minify JS, Cloudflare fonts, Rocket loader, and Compression. You can tweak these settings to speed up your website. Remember to test your site every time you turn on any feature.

#2 Optimize images

Images can make your website more engaging and attractive but can also slow the load time, especially if they’re high resolution. Consider using responsive images with smaller dimensions so that your website loads quickly.

Third-party tools

Converting the images to a browser-friendly file type optimizes them. WEBP is one of the most supported extensions, providing the best compression without reducing image quality. Here’s a list of some of the best websites to optimize and compress pictures.

Lazy loading

Lazy loading is the technique by which images are only loaded after the other elements of the page are loaded or as the visitor scrolls through the page, reaching the section where the relevant image must be viewed in the browser viewport. As opposed to “eager” loading, lazy loading allows the page to load faster if the larger images are not required for painting the screen active in the browser viewport.

Every CMS provides an option to lazy load the images. You can also add a loading attribute with a value of “lazy” so the browser knows which images to load in lazy mode. Here’s a guide from W3Schools if you want to learn more about lazy loading.

#3 Optimize your website’s code

Optimizing the website code can also help boost its performance. Javascript and CSS are among the main culprits slowing down your website. Consider minifying and combining the JS and CSS files to improve your website's loading time.

Plugins like WPRocket and 10Web can combine JS and CSS files and easily minify your code. Installing them can reduce your website's bloat with just a few clicks.

Asynchronous and Defer Javascript

Both async and defer are HTML attributes that optimize JavaScript loading without impeding page rendering. However, they employ different execution strategies:

Async Attribute:

  • Fetches scripts in parallel with low resource priority
  • Executes scripts immediately upon download completion
  • May momentarily pause DOM construction for script execution
  • Runs scripts in a "first-downloaded, first-executed" manner

Defer Attribute:

  • Also retrieves scripts in parallel with low-resource priority
  • Postpones script execution until DOM parsing is nearly complete
  • Maintains the original script order during execution
  • Fires just before the browser triggers the DOMContentLoaded event

In essence, async prioritizes speed and independent execution, while defer ensures orderly script execution aligned with DOM readiness.

Combine plugins when possible

Plugins are like shortcuts to adding custom functionality to your website. Depending on their compatibility with your theme, quality, and usage, plugins can either help or hurt your website. You must use lightweight, well-coded plugins that don’t affect your website speed but align with your website theme.

Most importantly, combining plugins reduces HTTP requests because most plugins are JavaScript-based. For example, don’t use two different plugins to compress images in one step and convert them to WEBP in a second step. Instead, you can use a single plugin like LiteSpeedCache that compresses and converts the images. Keep the plugins updated and delete the inactive ones.

Use lightweight themes

Most modern themes are lightweight and provide complete customization control. However, due to competition, some themes are loaded with custom code to offer extra unnecessary features. More code increases the overall size of the web pages and requires more assets like scripts, stylesheets, and images, leading to an increase in the number of HTTP requests. These factors can decrease your website's performance. Instead, update a lightweight theme frequently to keep it as fast as possible.

#4 Treat mobile users as first-class citizens

According to a study, there are 5.4 billion mobile internet users globally. Eighty percent of users access a website using their mobile devices.

Most developers build a theme on their desktop devices and later improve it for mobile as an afterthought. Instead, consider a mobile-first design for your website. You could also build a separate mobile version. Google started mobile-first indexing by its search engine back in 2016 when it recognized the importance of this issue.

Another solution is AMP (Accelerated Mobile Pages), an open-source framework for creating fast-loading mobile web pages. Google first used AMP in 2016 to compete against Apple News and Facebook Instant Articles.

Below are the pros and cons of using AMP:

Pros Cons
Page loading is nearly instant. Requires developer to become familiar with AMP.
Improves user experience on mobile. There aren’t many options when designing your page.
Supported by almost every big platform like Google and Bing. AMP allows only one advertisement on a single page.

If your website is hosted on WordPress, you must check to ensure your theme supports AMP, as not all themes do.

#5 Solve the LCP of the page

Largest Contentful Paint (LCP) is the largest element on your page and one of three crucial core web vitals. Google considers a good LCP score to be between 0-2.5 seconds.

Three key factors negatively impact your LCP score

  • Render-blocking JS and CSS that the browser must download, parse, and run before rendering.
  • Slow origin server response time.
  • High resource load time like high-definition images and custom Google fonts.

To solve it, you’ll have to audit your site to identify the LCP. You can use the WebPageTest tool to do this. Here are some typical solutions:

LCP Solution
Image
  • Change the dimensions of the image and make them responsive

  • Compress the images using third-party tools

  • Convert the PNG and JPEG images to a browser-friendly extension like Webp.

Text
  • Reduce the size of the text

  • Consider using fonts like sans-serif and Arial

  • Use Swap font property

#6 Optimize website hosting

There are three types of hosting

  • Shared hosting
  • Dedicated server
  • Virtual Private Server (VPS)

Shared hosting is the most affordable way to get your website online. However, because multiple domains are on a single server, shared hosting can slow down your site if other domains have bursty traffic, sometimes called the “noisy neighbor syndrome.” You also get limited capacity, and performance drops as your traffic scales.

If you don’t have many visitors to your website, you can use a combination of shared hosting and Cloudflare integration to get your site running. You can use different features of Cloudflare, like “Always Online,” to get the most out of it.

VPS is the optimal hosting solution for medium-sized websites. Amazon LightSail is an example of an affordable cloud hosting solution for small and medium businesses.

#7 Database optimization

Database optimization includes optimizing the queries. Monitor your database performance regularly. Caching stores data temporarily and more effectively than conventionally stored data. This helps improve the response time, reduce latency, and improve the performance of your content.

If you’re on WordPress, use plugins like LiteSpeed Cache and Wp-Rocket to clear the transient, drafts, and revisions to reduce the size of the database. Revisions are created whenever you save a post before publishing. If you save a post ten times while writing, it will create ten unnecessary revisions. These revisions will be stored in your database, increasing its size.

Most hosting providers offer free features to optimize the database automatically, which can also help improve the performance of your content.

#8 Try to avoid loader and animation

If you’re using a preloader, it may block the page's FCP. FCP (First Contentful Paint) is another crucial performance metric that measures the point in time when the first content from the DOM is displayed. FCP could be an image, text, SVG, or <canvas> element. A site should have a First Contentful Paint of 1.8 seconds or less to provide a good user experience.

Tools like Google’s PageSpeed Insights show an error whenever you use a preloader on a website. This can affect your Google rankings because core web vital signals are considered when calculating a ranking score. Using too many animations, such as fade-in and fade-out, can also slow down your website.

#9 Mind the full transaction path

Once the frontend, hosting, and database services are tuned, other factors can still affect the user experience. Worse, they can go unnoticed for a long time if you are unaware of them. For example, a slow-performing Domain Name System (DNS) would result in a bad user experience before they even reach your website.

The transaction path between the end user and the application's front end traverses several routers and links operated by various third-party Internet service providers. This means that all the systems you directly control might be performing at their peak even though the end users experience a slow application service on your website.

Catchpoint defines the concept of an Internet Stack to capture the full context and “Internet core” to designate the segments typically beyond the control of the IT teams managing websites. See the diagram below for a visual depiction of these concepts

The Internet Stack includes the domain name and Internet services

A practical solution to knowing about slowdowns in the portions of the Internet stack that you don’t directly control is to use an Internet Performance Monitoring (IPM) service that pinpoints the performance bottlenecks in what Catchpoint coined as an Internet Stack Map, shown below. These components include the DNS, CDN, third-party APIs, and connections between internet service providers (ISP) enabled by the Border Gateway Protocol (BGP), which are monitored by IPM providers.

An Internet Stack Map highlights the slow Internet services

Catchpoint’s Internet Stack Map is integrated with two types of web performance monitoring services to provide a consolidated view of the user experience, which is the topic of our next section.

Types of web performance monitoring

There are two important types of web performance monitoring

  1. Synthetic monitoring
  2. Real-user monitoring (RUM)

Synthetic monitoring emulates end-user transactions using scripts to validate and measure performance from multiple global test points from the networks of various internet and wireless service providers. It can help identify and fix issues with website availability, website uptime, issues users might face, and how well your website is performing.

Synthetic monitoring can

  • Monitor the performance of a website daily
  • Identify performance-related issues and solve them
  • Discover the issues users might face even before end-users experience them

RUM tracks performance data from real users accessing your website or application. It uses a script to measure and load the page data and then collect performance metrics from the user browsers.

Combining both types of monitoring helps you get a complete picture of the user experience.

Conclusion

Website performance optimization isn’t just about improving your website's performance and speed. It’s about enhancing user experience to get better SEO rankings and drive more traffic to your website. Website performance is a direct ranking factor in Google. Optimizing your website can be challenging but positively affect your business.

You don’t need to follow all the recommendations in this article; spend some time researching them and applying them individually. If you get a better score after applying some techniques, keep optimizing. It is the best way to get your website ranking higher on Google.