Top Front-end Performance Optimization Techniques to Use

Estimated reading time: 18 minutes
March 31, 2021
Updated on May 23, 2022
Top Front-end Performance Optimization Techniques to Use
Estimated reading time: 18 minutes
March 31, 2021
Updated on May 23, 2022
Top Front-end Performance Optimization Techniques to Use
Estimated reading time: 18 minutes
March 31, 2021
Updated on May 23, 2022
  • /
  • /
Content Marketologist
Written by
This article was written
in collaboration with
Denis Z. — CTO and
Zhanna F. and Aleksandr K. — Web Developers at Aspirity
1..2..3… and then they leave and never come back. If the pages of your site are loading for more than 3 seconds, people will start to abandon it before it's fully loaded. The number of users leaving the page grows every second of that loading time. So what can you do to prevent it from happening?

There is a way out of this situation: front-end performance optimization. It positively affects customer perception, increases conversion rates, and ultimately affects your project's success. In contrast, poorly optimized websites take a lot of time to load, are data-heavy, and require high network bandwidth making them non-mobile ready.

According to one of the latest Google updates, there is a whole set of factors to consider when evaluating user interaction with the site. Core Web Vitals have become the basis of the new metric with the most significant impact on page quality scores. They also affect the website's position in Google search results.

Using front-end performance optimization techniques listed and explained in our post will help you improve your app's score on all these metrics. Thus, your site will become any user's best friend.

Frontend performance optimization is a significant part of the projects we at Aspirity deal with. That's why we have deep experience in this regard and want to share some valuable insights with you. Read further to find out the web performance optimization techniques you need to know.

Why Front-end Performance Optimization is Crucial for Your Business?

Whether you run an eCommerce store, a content website, or a web app offering your services or products, front-end performance is one of the keys to your success. Why? Because it's directly related to speed, accessibility, and usability. A slow-loading and inconvenient page will cause frustration, repel users, and increase churn rates.

Therefore, if you want to retain more customers and scale up your business, improving your website's performance is vital. Let's find out why optimization matters and what kind of benefits it can provide.

Better Conversion

The world is getting faster. Users hate to wait. Visiting your website, they expect a quick, frictionless journey to their destination. And if your page loads too slowly, most visitors will take the easiest path: they will leave.

Website performance optimization is the way to escape this scenario. As a result, you increase conversion rate, the key metric for most online businesses. According to a study, 46% of users bounce if a landing page loads longer than five seconds. Ideally, the loading time shouldn't be more than three seconds.
And it's not just a figure, but a real value proven by numerous world-famous examples. From Pinterest and Yahoo! to Tokopedia and, they all reported a direct impact of page load time on their conversion rates.

So if you want to retain your website visitors and convert them into actual customers or subscribers, optimizing your front-end performance is the first step.

Improved SEO Strategy

Good front-end performance is an integral part of the Search Engine Optimization (SEO) strategy. In 2010, Google announced that site speed would greatly impact site ranking. So if your page loads slowly, it has no chance of appearing at the top of search results.

Do you think that content is more important than speed? Well, you're right. But that's us, humans. Search engines have their methods for assessing your content relevance. And your site's performance is one of the critical factors.

It's easy to explain: the higher the load time — the more users leave your page. Accordingly, it signals the search engine that your content is not satisfactory enough. Thus, to increase your brand awareness and optimize your SEO, you should monitor the performance and improve it.

Usability and Accessibility

Finally, improving your front-end performance is closely related to user experience and accessibility. As mentioned above, the users don't appreciate poor loading speed. What's more, your site may be entirely inaccessible for specific audience groups. For example, a Microsoft study claims that 71% of people with disabilities will leave your website immediately if it's not accessible for them.

It's not only about the page's speed but the overall performance. There are numerous ways to track and evaluate those aspects of your website, including a comprehensive accessibility audit. Also, multiple tools, including the Lighthouse, can report the potential issues in this regard.

Front-end Optimization Techniques

Now you know about the critical impact of frontend optimization on your business success. Time to learn how you can implement it.

In our article, we've collected time-tested and result-driven methods that allow for optimizing your website or web app. In particular, we will reveal the following techniques:
  • Image optimization
  • Responsive images
  • Video optimization
  • Font optimization
  • Code performance improvement
  • Caching
  • Content Delivery Network (CDN).
But before we move on to describe these optimization approaches, let's talk about the metrics that enable monitoring your frontend performance.

So what are Core Web Vitals, and what kind of information can they provide?
Looking for relevant cases?

What are Core Web Vitals?

Core Web Vitals are new metrics introduced in May 2021. Since then, they've played an essential role in ranking a website in search engines. Core Web Vitals is an umbrella term for new resource quality factors.

Here are three Core Web Vitals explained in terms of their critical impact on front-end optimization (FEO).
  • LCP — Largest Contentful Paint
    determines how quickly the site's largest and most important content loads.
  • FID — First Input Delay
    determines how quickly a user can start interacting with the site (click, scroll, etc.)
  • CLS — Cumulative Layout Shift
    determines how much the layout is shifted and if it's stable or not.
Along with optimizing Core Web Vitals, Google provides various tools that can help you start improving your website performance. These services include Search Console's report, PageSpeed Insights, and Lighthouse.
These and other tools are essential for developers who aim to improve web performance. We offer you a closer look at some of the most problematic areas that affect the site's score for these key metrics. Also, you will learn how to address these challenges. Finally, we will specify how a particular technique affects Core Web Vitals.

Optimize Images for Better Web Performance

Images are a crucial feature for many sites. Without them, we would be looking at plain text lines. But large high-resolution images can significantly slow down the loading process making websites heavy and slow. Thus, optimizing images is a crucial point for front-end web performance improvement.

Simply put, the more time it takes to upload the images on your site, the worse the LCP indicator will be.

There are several different image optimization techniques. We recommend trying some of them to boost the website performance.

Pick the Right Format

Standard image formats contain much additional information that increases their initial size. They are not used in any way on the website but can increase the loading time for your users. So it's a good idea to consider compressing such images with external tools like MozJPEG or Guetzli. Or you can simply turn those images into WebP files.

WebP images are 25 – 35% smaller than typical images like JPEG and PNG. Simply switching all images to WebP can decrease the web page's size, making it faster to load. Besides, this format is supported in all frequently used browsers so you don't have to worry about your images not showing up to users.

However, we should warn you that WebP has its downside too. This format doesn't support progressive rendering so it might take some time for users to finally see the image.

Turn to Squoosh

You can use Squoosh to get smaller images. This tool is made by the Google team. Squoosh supports a bunch of formats and fine-tuning for each of them. Besides, it is also available as a CLI application for easy integration into the automation pipeline.

What's the key advantage of Squoosh? It allows achieving the desired balance in the image's size and quality. For example, you have a beautiful picture designed for your website cover. However, it's too large and doesn't allow your page to load fast enough.

Using Squoosh, you can simply open your image in the app, reduce its size, change the format, and compare its quality to the original file. Once you find the right balance, you can download your image and use it to enhance the website's loading speed.

Use Lazy Loading Images

You may also pay attention to lazy loading images. It will allow postponing the content loading until the moment those images are in the viewport. For example, when a user will initially open the page, all the images on it will be loaded during the scrolling process.

This approach will help you accelerate page load times, shorten the length of critical rendering steps, and utilize the device's resources. Thus, you will both improve your frontend optimization and boost user experience.

The main idea of lazy loading images is triggering a load of a particular image only when it becomes visible to the user. You can check which images can work with this technique and how many bites you can save by applying it with Google Lighthouse audit.

The most common way to implement lazy loading is using the <img> tag. For that, the browser applies the src tag attribute. Then, it triggers the image's load, regardless of the order in HTML. You can prevent the load by putting its URL into another attribute like data-src instead of src. This way, the browser will stop triggering the image load:

<img data-src=""  src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P+/HgAFhAJ/wlseKgAAAABJRU5ErkJggg==">

is a result after converting image to Base64. You can do it online or with a PHP script.

Here is an example from GitHub showing how lazy loading works.

Use Responsive Images for Front-end Performance Optimization

Images often take almost half of the page size. It is especially so for the media-heavy sites. That's why we recommend turning to responsive images. They will allow you to optimize the website's performance by reducing the time needed for image delivery.

Responsive images provide appropriately scaled images depending on the user's screen resolution. They change depending on the display resolution on which they are viewed, allowing you to keep what you need in focus.

Here's an example. Suppose you want to place a hero image on your website's home page. However, depending on the visitors' devices, the image's size — and loading speed — will be different. So it makes sense to allow it to adapt to the users' screens and make it responsive, like in this example.
And here's the simplest way to make your responsive image scale both up and down:

<source srcset="smaller.jpg" media="(max-width: 768px)">
<source srcset="default.jpg">
<img srcset="default.jpg" alt="My default image">

Also, you can optimize images for Retina displays. To do this, you should specify one more picture after a coma and indicate that it’s for screens with higher pixel density:

<source srcset="smaller.jpg, smaller_retina.jpg 2x" media="(max-width: 768px)">
<source srcset="default.jpg, default_retina.jpg 2x">
<img srcset="default.jpg, default_retina.jpg 2x" alt="My default image">

Responsive Image Breakpoints Generator can make your life easier as it produces all the required versions of the images and the HTML code to insert them.

It is also worth remembering that until the picture is loaded, you need a placeholder of the correct size. Otherwise, it will affect the stability of the layout (CLS).
Have an amazing idea?
We will be happy to develop that idea into an MVP or a full fledge product!

Optimize Videos for Web Performance

When you're done optimizing images to improve front-end performance, think about optimizing videos. The wrong approach to placing video and other dynamic content on your page can lead to poor LCP and CLS performance.

To avoid these issues, you can switch from heavily animated GIFs that may take years to load fully. Or change the videos that slow down your website's loading time to a perfect format for the general front-end performance.

There are several video optimization techniques to make it easier for users to view your site, even if it consists of many media files. Here are some of the options to optimize website performance.

Use Data Compression

You can try using data compression tools that won't ruin video quality. Smaller files take less time to load. But don't compress them to the point where they look like animated GIFs. Try switching the format instead. As a result of compression, a 20 GB video file may take up twice less space, and, accordingly, your page will load faster.

Also, if a video goes with sound but you don't use it on your website, you can turn off audio tracking. It will help you reduce the overall file size.

Normally, video data compression requires standard techniques like Discrete Cosine Transform (DCT) and Motion Compensation (MC).

Opt for Looping HTML5 Videos

<video loop> tag makes your video repeat endlessly. Also, HTML5 gives you better control of the video player.

However, in many cases, GIFs may be lighter and smaller. For example, this is the case in transparent background videos. On top of that, you should remember that in such videos, the color will differ from the one you use for your website background. That's due to compression algorithms and other nuances.

There are several formats to choose from as well. MP4 and WebM are perfect for the web. Both of them pack high-quality videos into small file sizes. You can also go with AV1. This one is relatively new on the market, but it's gaining more and more attention among the community. It provides good compression (twice as good as WebM) and does it for free.

Specify the Size

If you place a video file in the background, it is advisable to use the minimum size with acceptable quality. We recommend compressing videos up to 720p at 25fps. In this case, you need to specify both vertical and horizontal dimensions of the video in HTML or CSS.

Thus, the browser will be able to determine the bandwidth on its own. And that will speed up the page load.

Don't Autoplay Videos

Simply defer videos from playing automatically and make them load after the initial page load is complete. You can also display a short loop or the first frame of the video as a still image until the entire video is buffered.

Disabling the autoplay feature makes your site run faster. It also significantly boosts user experience and reduces the visitors' frustration. According to a study, 92% of users feel annoyed when a video starts playing once they visit a website.
On top of that, autoplay makes your website unusable for disabled people, which is a major accessibility issue.

Optimize Fonts for Better Frontend Performance

Fonts are a significant part of your website's content. As a result, they may seriously affect your page's performance, especially the CLS indicator.

The more font styles and variants you use on your page, the more space they will take. However, likely, you won't need all those stylistic variants on your website. To address this issue and improve performance, you can turn to font loading and rendering customization.

For that, many developers turn to a resource prioritization feature. It's represented by <link rel="preconnect"> and <link rel="preload"> metatags. With their help, you will trigger a request to the browser, communicating the need to connect with relevant resources as early as possible.

For example, the following metatag can help you connect to Google Fonts faster.

<link rel="preconnect" href="" />
This approach is applicable for other content as well. For example, the following request may help you streamline the process of getting the files for your website.

<link rel="preload" href="style.css" as="style" />
Also, you can turn to the Font Loading API, which provides greater control over loading and rendering your font. Thus, you can monitor the downloading progress, correct lazyload behavior, and operate CSS fonts as required.

Find and Clean Out Unused Scripts and Code

Code cleanliness is another thing we must keep in mind for front-end web optimization. It critically affects First Input Delay (FID) indicator. Here are a few best practices that will help you optimize code quality for better website performance.

Track Your Code Performance

Google Chrome allows you to view which code has been loaded and used and which has remained unprocessed. You can reduce the page size by placing only the code you will use for the initial load. Also, you can turn to the Coverage panel in Google Chrome to find unused code and lazyload it.

Code Coverage panel is a helpful tool for developers provided by Google. This feature can inform you about the resource's URL, type (JavaScript or CSS), total size, and unused size. Finally, it will visualize the used and unused parts of the code. Thus, you can define what exactly affects your page's loading speed.

Reducing the unused lines in your code will unblock your website rendering and thus, improve its performance.
Finally, remember that the metrics like Facebook Pixel or Global site tag (gtag.js) may decrease download time. Thus, you can delay them with the help of a tool like Google Tag Manager.

Optimize CSS and JS Performance with Code Splitting

In addition, you can use a bundler to simplify the optimization process. It helps developers compile and organize all the project's resources. The bundle allows developers to divide the project into modules for better-organized work processes.

One of the most powerful bundlers is Webpack. We use it in all of our projects with the included front-end performance optimization for JS and CSS. We do this to keep the file size smaller and boost the website loading speed.
The larger your application gets, the larger the bundle will be. It may happen if you include massive third-party libraries. To keep track of the code and not miss the moment when the application becomes too large to load, you need to prevent the bundle from growing big in time.

You can use code splitting to do this. Applying this technique with a tool like Webpack, you divide your code into several bundles or components. In other words, you can reduce your JavaScript or CSS files that have grown in size by splitting them into multiple smaller ones. It will allow you to avoid downloading code that the user may never need. You will also lessen the amount of code required for the first load.

Here are several options that Webpack provides to split the code:
1. Manual split with the use of entry points. It's the easiest method which, however, may lead to unwanted challenges. In particular, these are poor flexibility and the risk of duplicated modules. Here's what the result of such a split may look like.
2. Using Entry dependencies or SlitChunksPlugin, you can split your code and prevent duplication. For example, splitting code with the plugin will look as follows:
3. The dynamic imports feature will allow you to split the code with the help of inline function calls. Here's an example of what it should look like:

Apply Minification Technique

Finally, the minification method can improve web performance, load time, and capacity as well. It reduces the file size by removing comments and unnecessary white spaces without changing the code's functionality. Some minifiers can even shorten variable names.

Minification is crucial for optimizing HTML, JavaScript, and CSS files. The developers often turn to spacing, comments, and variables naming to make the code clearer and more readable. However, these additional elements make it more difficult for browsers and web servers to analyze the content. Besides, they tend to create extra network traffic.

And that's where minification comes in handy. It helps the developers minimize the file size by removing all unnecessary comments and file names. In addition, minification affects website loading time as smaller file-sized scripts load much faster. It's also parsed faster because there are no comments or white spaces to ignore. Thus, less text takes up less memory.

Here is what an example code looked like initially:
And after minification, the same piece of code will look that simple:

Better Caching for Increasing Speed

Caching is one of the most well-known website optimization techniques to keep websites fast and scalable.

Once a user loads your website for the first time, their browser requests data from the server. Then users have to wait for the server to return the requested data before they can view your content. It may take a lot of time, but caching will help you save it.

Web cache is website data that a user's computer stores temporarily for quicker access. By creating such a static copy of your website's content, the cache allows users to browse through website pages without the need to download the duplicate files repeatedly. It also reduces the number of requests to the server. Which in turn, helps said server handle more users.

We recommend working on the browser cache. It's client-side caching. The browser can control the cache, refresh the content and delete unclaimed ones. It's built into the user's web browser. Browser cache can store website elements which consist of HTML pages, CSS stylesheets, JS scripts, and multimedia content.

For example, if a user has visited a website with multiple images, the browser will save them with the help of caching. Thus, a user won't have to re-download these images when they visit your page again. However, the first-time load will still be slow. Thus, the user may leave earlier than the caching technique will start working.

Therefore, we recommend that you pay no less attention to other web performance optimization options listed above.
Looking for a team?
We solve world-class front-end challenges using ReactJS and Flutter.

Increase Page Speed With a CDN

All those types of caching are a great option, but they have their limits for scaling websites for a broader audience. If you cater to a global audience, you'll need something more than that. That's when CDN comes to the scene.

CDN or Content Delivery Network is one of the server caching types and an excellent option to choose as one of the best website speed optimization techniques. It can also combat the physical distance between users and the website's hosting server. It allows users to send requests to the nearest server and reduces network latency problems.

CDN caches data on a globally distributed network of servers in different geographical locations. So that a user from the US won't have to wait for a European server to process the request as it will be sent straight to the US server. Such systems speed up the process of uploading content on the site.

CDN is great for storing static content that doesn't often change, such as different kinds of multimedia or JavaScript files.

Front-end Optimization Tools

Numerous robust tools and open-source platforms will allow you to implement the website optimization techniques we've explained in this article. We will provide a list of the most helpful and reliable ones for your convenience.

You can use these tools to boost various aspects of front-end performance with minimum effort.

Aspirity's Experience

We at Aspirity aim to optimize everything in our projects to make them easily delivered and implemented by the client. We don't run projects primarily focused on improving front-end performance. But our developers always pay special attention to optimization just because it's crucial.

In particular, we use Webpack on all our projects. And before deploying a website or app for our client, we regularly optimize JS and CSS files to minimize their size and make them load faster.

Also, our specialists often turn to virtualization and infinite scrolling. For example, in the iTraqButterfly project, we applied these technologies to allow the end-users to see as much data as possible without being overwhelmed.
We have also worked on a landing page that required special attention to image optimization. However, for our front-end developers, it was more of a mini-task rather than a primary goal.

Finally, working on the Shoreline project, we also had to use certain optimization techniques to streamline the users' access and allow them to work faster. However, Shoreline is a B2B solution that aims to make DevOps' lives easier. Thus, the performance improvements we applied had different goals and means of implementation.

Final Thoughts

There are many more techniques you can use to optimize your site. We have listed only some of the front-end performance best practices that are helpful for websites of different sorts.

If you are not a developer but still want to know how to optimize the front-end performance of your website, you can turn to our experts. We at Aspirity specialize in front-end and can help you understand the abundance of web performance optimization techniques. Thus, your site will be available to a more significant number of users.

Our team understands the importance of web performance optimization in creating websites that work. Get in touch with us to make your website optimized for different platforms.

Frequently Asked Questions

  • 1
    How to Improve Front-end Performance?
    There are numerous best practices for optimizing front-end and UI performance, making your website load faster. You can minify particular parts of your code, remove too heavy and unused fonts, compress your files, optimize images and videos, turn to lazy loading, apply the caching method, use a CDN, etc. There are many tools and platforms to implement these techniques. Or, you can turn to a professional team of front-end developers who will do it for you.
  • 2
    How Can I Improve My HTML Performance?
    A few result-driven methods will help you improve your HTML performance. First, you can clean up your HTML code to avoid unnecessary inlines, scripts, and blank lines. Second, you can compress your HTML server-side files. And third, you can turn to additional optimization techniques like minification and caching.
  • 3
    What Are the Costs of Front-end Optimization?
    The price of front-end performance optimization depends on multiple factors that affect such a project's complexity and scope. Among these factors, you should consider the project's size, the nature of the challenges you face, and the desired outcomes. The professionalism and location of the hired tech partner also matter.

    We don't provide front-end optimization as a separate service. Usually, it comes with the whole front-end if our clients need it. Therefore, we cannot provide any prices to go with this article. But we can offer to get our pricing manual with different scopes of work to choose from.
  • 4
    What Are the Factors in Optimizing Website Performance?
    Multiple factors affect the process of website optimization. You can track and assess your site's performance with tools like Lighthouse, Code Coverage Panel, Page Speed, YSlow, WebPagetest, etc. If you see that your page loads too slowly, has poor accessibility, or experiences SEO issues, it's a sign to think about improving your front-end.
This article was written in collaboration with Denis Z. — CTO and Zhanna F. and Aleksandr K. — Web Developers at Aspirity
Content Marketologist at Aspirity
I've been doing a huge chunk of Aspirity's marketing communications for almost two years. I help clients understand how our team can solve their problems.
Written by

Want to know more?
Read our other articles
Considering building scalable React apps but still not sure if it's a good idea? Here's the list of the main benefits of using React for any sized project.
Is insurance digital transformation and digitization relevant for your industry? Read on to see how to minimize the main challenges of digitizing in the insurance industry.
How to choose telecom expense management software? What are the benefits of a TEM system, and how to implement it most efficiently?
Eager to obtain a custom design for a real estate website? Check out the best practices and get blown away by the examples of innovative websites.
Why is ERP system user experience (UX) design important? Investigation through challenges and best practices, as well as examples of great ERP design implementation.
Building custom software or have an existing one?

Aspirity is an offshore web development agency. We specialize in management, admin, and dashboard software.

If you have a custom software project — contact us for a confidential consultation or just read more from our blog.

If the article seemed interesting to you, share it with your friends