How To Optimize Website Speed
Contents
- 1 How To Optimize Website Speed
- 2 How To Speed Up First Contentful Paint (FCP)
- 3 How Speed Up Largest Contentful Paint (LCP) With DebugBear’s Recommendations
- 4 Monitor Your Site Speed With DebugBear
- 5 Which is better k6 or JMeter?
- 6 What to do after launching a website?
- 7 Is Java required for JMeter?
- 8 What are testing techniques?
Running a speed test is the first part of your website optimization journey.
Once you have your measurements, you need to know how to interpret them and what to do to correct them.
In the Metrics Overview area of your website speed report, you can see the key metrics we’ll focus on to help speed up your site:
Additionally, you can use the request waterfall to see how long requests are taking and how that affects these metrics.
How To Speed Up First Contentful Paint (FCP)
Let’s start by making your website appear faster for your visitors; we’ll tackle First Contentful Paint first.
What Is First Contentful Paint?
First Contentful Paint measures how quickly a page’s content first starts to appear after your visitor navigates to that page.
It is important that your key content appears quickly to prevent your visitors from leaving your site. The faster a user leaves your site, the faster Google learns that the page experience may be poor.
But how do you know exactly what is causing your site to load slowly?
How do you uncover which server issues are slowing down your website? Let’s find out.
Why Is My First Contentful Paint Taking So Long?
Your FCP can be affected by server connection speed, server requests, render-blocking resources, and more.
It sounds like a lot, but there’s an easy way to see exactly what’s slowing down your FCP – the request waterfall.
This useful tool shows which requests are made by your website and when each request starts and ends.
For example, in this screenshot we see first a request for the HTML document and then two requests to load stylesheets referenced in the document.
Screenshot showing debugging data for the First Contentful Paint metric in DebugBear, October 2022
Why does the first meaningful paint happen after 0.6 seconds? We can break down what is happening on the page to understand this.
Understanding What Happens Before A First Contentful Paint
Before the first pieces of content can be loaded on your web page, your user’s browser must first connect to your server and retrieve the content.
If this process takes a long time, then it takes a long time for your user to see your website.
Your goal is to learn what’s going on before your site starts to load, so you can pinpoint problems and speed up the experience.
Page Loading Part 1: The browser establishes a server connection
Before you first request a website from a server, your visitor’s browser must establish a network connection to that server.
This typically takes three steps:
These three steps are performed by the browser one after the other. Each step requires a round trip from your visitor’s browser to your site’s server.
In this case, it takes about 251 milliseconds to establish the server connection.
DebugBear screenshot showing the network roundtrip used to establish a server connection, October 2022
Page Load Part 2: The browser requests the HTML document (time to first byte happens here)
Once the server connection is established, your visitor’s browser can request the HTML code that contains the content of your website. This is called an HTTP request.
In this case, the HTTP request takes 102 milliseconds. This duration includes both time spent on the network round trip and time spent waiting for the server to generate a response.
After 251 milliseconds to establish the connection and 102 milliseconds to make the HTTP request, your visitor’s browser can finally start downloading the HTML response.
This milestone is called Time to First Byte (TTFB). In this case, it happens after a total of 353 milliseconds.
When the server response is ready, your visitor’s browser spends some extra time downloading the HTML code. In this case the response is quite small and the download only takes another 10 milliseconds.
DebugBear screenshot showing the various components of an HTTP request, October 2022
Page Loading Part 3: Your site loads additional render-blocking resources
Browsers do not render or display pages immediately after loading the document. Instead, there are usually additional render-blocking resources.
Most pages would look bad without visual styling, so CSS stylesheets are loaded before a page starts rendering.
Loading the 2 additional stylesheets in this site speed test sample takes 137 milliseconds.
Note that these requests do not require a new server connection. The CSS files are loaded from the same domain as before and can reuse the existing connection.
DebugBear screenshot showing additional render-blocking resources being loaded after the HTML document, October 2022
Page Loading Part 4: The browser renders the page
Finally, once all the necessary resources have been loaded, your visitor’s browser can start rendering the page. But doing this work also takes a certain amount of processing time—in this case, 66 milliseconds. This is indicated by the orange CPU task marker in the waterfall view.
DebugBear screenshot showing the steps from loading the HTML document to rendering the web page, October 2022
We now understand why FCP happens after 632 milliseconds:
The other processing work includes small tasks like running inline scripts or parsing the HTML and CSS code once it’s downloaded. You can see this activity as small gray lines just below the rendering filmstrip.
How To Optimize First Contentful Paint (FCP)
Now that you understand what drives your website to be rendered, you can think about how to optimize it.
Now that the first parts of your site are loading faster, it’s time to focus on making the entire site load faster.
How Speed Up Largest Contentful Paint (LCP) With DebugBear’s Recommendations
There are many ways to speed up your LCP.
To make it easy, DebugBear gives us great next steps in their recommendations section.
Let’s take a look at some examples of the recommendations and learn how to speed up this website’s LCP.
Recommendation 1: Initiate LCP Image Requests From The HTML Document
If the largest content element on your page is an image, the best practice is to ensure that the URL is directly contained in the initial HTML document. This will help it start loading as quickly as possible.
However, this best practice is not always used and sometimes it takes a long time for the browser to recognize that it needs to download the main image.
In the example below, the largest content, which is an image, is added to the page using JavaScript. As a result, the browser must download and run a 200-kilobyte script before it detects the image and starts downloading it.
DebugBear screenshot showing a sequential request chain leading up to an image request, October 2022
How to fix: Depending on the site, there are two possible solutions.
Solution 1: If you use JavaScript to lazy load a large image, optimize the image size and remove the lazy loading script or replace it with the modern loading=”lazy” attribute, which does not require JavaScript.
Solution 2: In other cases, server-side rendering would prevent you from having to download the JavaScript app before the page can be rendered. However, this can sometimes be complicated to implement.
Recommendation 2: Ensure LCP Images Are Loaded With High Priority
After loading the HTML code on a page, your visitors’ browsers may find that, in addition to your main image, it may need to load a large number of additional resources such as stylesheets.
The goal here is to ensure that your larger main image loads to meet Google’s largest content paint requirements.
Other resources, such as third-party analysis scripts, are not as important as your main image.
Additionally, most images referenced in your site’s HTML will be below the separator line once the page has been rendered. Some may be hidden entirely in an embedded header navigation.
Because of this, browsers are set to start by prioritizing all image requests to Low. When the page is rendered, the browser finds out which images are important and changes the priority. You can see an example of it in the screenshot below, as indicated by the star in the priority column.
DebugBear screenshot showing an LCP image loading with low initial priority, October 2022
The waterfall shows that although the browser knew about the image early, it did not start downloading it, as indicated by the gray bar.
How to fix: To fix this, you can use a new browser feature called priority tips. If you add the attribute fetchpriority=”high” to an img element, the browser will start loading the image right from the beginning.
Recommendation 3: Don’t Hide Page Content Using CSS
Sometimes you can look at a request waterfall and all the render-blocking resources are loaded, but still no page content is displayed. What happens?
A/B testing tools often hide page content until test variations have been applied to content elements on the page. In these cases, the browser has rendered the page, but all content is transparent.
What can you do if you can’t remove the A/B testing tool?
How to fix: Check if you can configure the tool to hide only content affected by A/B tests. Alternatively, check if there is a way to make the A/B testing tool load faster.
DebugBear screenshot showing a rendering moviestrip with content hidden by an A/B testing tool, October 2022
Monitor Your Site Speed With DebugBear
Do you want to continuously test your website? Try our paid monitoring tool with a free 14-day trial.
That way, you can check if your performance optimizations are working and be alerted to any performance regressions on your site.
Screenshot showing site speed trends for a website in DebugBear, October 2022
The opinions expressed in this article are those of the sponsor.
Which is better k6 or JMeter?
k6’s comparatively better performance means it needs fewer load generators to carry a given amount of load. Rafaela Azevedo did a comparison of the memory used by k6 and JMeter and here are her results: JMeter took up 760 MB of memory. Meanwhile, the k6 took up 256MB of memory.
Which tool is better than JMeter? Loadrunner from Micro Focus is a widely used Load Testing tool. It is one of the best alternatives to JMeter that offers a user-friendly monitoring and analysis interface with colored charts and graphics. Features: Supports continuous testing.
Which performance testing tool is best?
Top performance testing tools
- WebLOAD.
- Load Ninja.
- HeadSpin.
- ReadyAPI performance.
- LoadView.
- Keysight’s Eggplant.
- Apache JMeter.
- LoadRunner.
Which is the best open source tool for performance testing?
JMeter. JMeter is the most popular open source load testing tool with almost as many features as commercial tools. You can record test scripts, run large-scale load tests, and view various performance metrics in easy-to-understand charts.
Is k6 better than JMeter?
Reviewers felt that k6 meets their business needs better than Apache JMeter.
Is JMeter the best performance testing tool?
JMeter is a highly competent tool that can handle load and performance testing for various products, regardless of server or protocol. Be it HTTP or HTTPS web services, database, FTP, LDAP, MOM (Message Oriented Middleware) through NoSQL (MongoDB) and JMS.
Is k6 good for load testing?
Anyone looking to perform stress testing highly recommends using k6.
Is k6 good for load testing?
Anyone looking to perform stress testing highly recommends using k6.
What is k6 used for?
k6 is an open source framework built to make performance testing fun for developers. k6 stands out for its ability to encapsulate ease of use and performance while also bringing together tools like a command line interface to execute scripts and a dashboard to monitor test run results.
What is k6 for load testing?
Grafana k6 is an open source load testing tool that makes performance testing easy and productive for engineering teams. k6 is free, developer-centric, and extensible. Using k6, you can test the reliability and performance of your systems and catch performance regressions and problems earlier.
What to do after launching a website?
13 Things to Do After Launching a Website
- Tell your team.
- Test all your forms, links and widgets.
- Check your site’s speed and mobility friendliness.
- Start backing up your site.
- Configure Google Analytics.
- Configure Google Search Console.
- Set up Google Alert mentions.
- Create a plan for ongoing maintenance.
What comes after product launch? Opportunity assessment. Another common practice for PMs after a product launch is to start planning the next phase of the product. Often this involves creating a feasibility assessment which provides the business case and vision for future versions of the product.
Is Java required for JMeter?
There is only one prerequisite for downloading and installing JMeter: having Java installed on your system.
Does JMeter require JDK? JMeter is a framework for Java, so the very first requirement is to have the JDK installed on your machine.
Which language is required for JMeter?
The Groovy language is used as the scripting language for JMeter. When it comes to enhancing JMeter’s functionality, Groovy has proven to be a powerful, yet lightweight, language in terms of performance.
Is JMeter written in Java?
JMeter is written in Java, so all JMeter entities – such as sampler, cache, listener, result – are described in the associated Java classes.
Is coding required for JMeter?
Knowledge: Jmeter does not require extensive programming knowledge.
What language is used in JMeter?
Is JMeter Java based?
What is JMeter? Apache JMeter is an open source, purely Java-based software. The software is used to perform performance testing, functional testing and load testing of web applications.
What is JMeter in Java?
What is JMeter? Apache JMeter is an open source, purely Java-based software. The software is used to perform performance testing, functional testing and load testing of web applications. It is used to test load test functional behavior and measure performance.
Is coding required for JMeter?
Knowledge: Jmeter does not require extensive programming knowledge.
Do we need to learn Java for JMeter?
Prerequisites. Before proceeding with this tutorial, you should have a basic understanding of the Java programming language. Since you need to use jMeter to perform all types of testing (regression, functional, load, performance, etc.)
How much Java is required for JMeter?
Prerequisites for installing JMeter JMeter is a pure Java desktop application. It requires a fully compatible JVM 6 or higher. You must download and install the latest version of the Java SE Development Kit.
Is coding required for JMeter?
Knowledge: Jmeter does not require extensive programming knowledge.
Which version of Java is required for JMeter?
If you plan to do JMeter development or want to use Sun’s Java Standard Extension packages, use one or more optional packages listed below. If you want to build the JMeter source or develop JMeter plugins, you need a fully compatible JDK1. 3 (1.4 for JMeter 1.8) or higher compiler.
Which Java version is required for JMeter 2.2 or higher?
2.1.1 Java version JMeter requires a fully compatible JVM 1.4 or higher. Version 2.2 and later no longer support Java 1.3. Because JMeter only uses standard Java APIs, please do not submit bug reports if your JRE cannot run JMeter due to JRE implementation issues.
What are testing techniques?
Software testing techniques are the ways used to test the application under test against the functional or non-functional requirements gathered from the business community. Each testing technique helps to find a specific type of defect.
.