Measuring performance and real-user experience is a crucial aspect of web development. It helps you identify areas for improvement and optimize your website for better user engagement.
A good starting point is to measure page load times. As we discussed in the "Understanding Page Load Times" section, a slow page load time can lead to a high bounce rate and decreased user satisfaction.
For instance, a 1-second delay in page load time can result in a 7% reduction in conversions. This is a significant impact that can't be ignored.
To accurately measure page load times, use tools like WebPageTest or Google PageSpeed Insights, as mentioned in the "Choosing the Right Tools" section. These tools provide detailed information on page load times, including the time it takes to load each resource.
The "Real-User Monitoring" section highlights the importance of monitoring real-user behavior. By analyzing real-user data, you can gain insights into how users interact with your website and identify areas for improvement.
The Problem
Measuring the speed and performance of your website is crucial, but it's not always easy to get an accurate score from your development environment. PageSpeed Insights needs a URL to be publicly available on the internet to run its analysis engine.
Local environments aren't publicly accessible, which makes it challenging to get a PagesSpeed Insights score from your development environment. This is a major problem for web developers who need to test and optimize their website's speed and performance.
Solution
To measure page speed on your local environment, you have a few solutions at your disposal. One option is to use Chrome Devtools, specifically Lighthouse, which allows you to measure page speed on a local environment.
Lighthouse in Devtools has a few configuration options, including choosing the device and connection type, and selecting the categories of test. It's recommended to leave all categories on to see their scores, but you can remove some if the tests are taking too long to execute.
You can use Ngrok to make your localhost temporarily available on a public URL, which is necessary for using PageSpeed Insights. This is especially useful for developers who want to demo their work without deploying it to a staging environment.
Here are the steps to set up Ngrok:
- Install Herd, a lightweight local development environment.
- Navigate to the website directory in your terminal.
- Run valet share.
- Copy the URL that is output in the terminal.
- Paste it into PageSpeed Insights to trigger a scan.
Ngrok Solution
Ngrok is a great tool for making your localhost temporarily available on a public URL. This is useful for developers who want to demo their work without deploying it to a staging environment.
You can use Ngrok with Laravel Herd, a lightweight local development environment that works with all PHP applications, including WordPress.
To set up Ngrok, install Herd, navigate to the website directory in your terminal, and run the command `valet share`. This will output a URL that you can copy and paste into PageSpeed Insights to trigger a scan.
Here's a step-by-step guide to setting up Ngrok:
- Install Herd
- Navigate to the website directory in your terminal
- Run `valet share`
- Copy the URL output in the terminal
- Paste it into PageSpeed Insights to trigger a scan
Using Ngrok opens the door to more advanced PageSpeed Insights local testing across multiple pages. With a public URL, you can automate PageSpeed Insights scans or run a bulk page speed test across your entire site before deploying it.
Recursive Comment Rendering for Developer Site
We're a community of developers sharing knowledge and growth opportunities. Our site is a place where coders can stay up-to-date and advance their careers.
One key feature we're working on is recursive comment rendering, which will enhance the user experience for our developer content creation site. This feature is crucial for our community.
By implementing recursive comment rendering, we can create a seamless and engaging environment for our users. This will help us achieve our goal of providing a platform for coders to share and grow.
The site's mission is to be a place where coders share, stay up-to-date and grow their careers.
Performance Metrics
Performance metrics are a crucial aspect of web development, and there are several key metrics to focus on. The Top 10 Most Important Website Performance Metrics & KPIs Developers Should Measure article highlights the importance of website performance in user experience.
To measure website performance, developers can use real user monitoring tools like Sematext Experience. This tool allows you to monitor your Apdex score, optimize Single Page Applications (SPA), and see underperforming resources.
A Distribution and selected metric values report can provide a clear picture of website performance. This report shows the distribution of metrics such as Largest Contentful Paint (LCP) and Cumulative Layout Shift (CLS), categorized as Good, Needs Improvement, and Poor.
The Performance category also includes metrics like First Contentful Paint, Largest Contentful Paint, Speed Index, Cumulative Layout Shift, Time to Interactive, and Total Blocking Time. Each metric is scored and labeled with a green circle (Good), amber informational square (Needs Improvement), or red warning triangle (Poor).
The 75th percentile is chosen for all metrics to ensure that pages work well for the majority of users, even under difficult device and network conditions. This is because variability in performance measurement is introduced via various channels, including local network availability, client hardware availability, and client resource contention.
Here are some key performance metrics to track:
- Time to Interactive (TTI): measures the time until the application is rendered and can respond to user input
- Time to First Byte (TTFB): measures the time the first byte of each file reaches the user's browser after a server connection has been established
- Peak Response Time (PRT): measures the longest response time for all requests coming through the server
- Error Rate: tracks the percentage of request issues in relation to the total number of requests
These metrics are essential for ensuring a smooth user experience and can be tracked using real user monitoring tools. By monitoring these metrics, developers can identify areas for improvement and optimize their website or application for better performance.
Measuring Performance
Measuring Performance is crucial to ensure a smooth user experience on your website. To start, you need to understand what metrics to measure, which are Apdex score, First Paint (FP), First Contentful Paint (FCP), Time to Interactive (TTI), Time to First Byte (TTFB), Peak Response Time (PRT), and Hardware utilization.
You can calculate the Apdex score using the formula: (Satisfied count / Total samples) + (Tolerating count / 4 / Total samples). This score will give you an idea of user satisfaction based on response time. Real-user experience data can be obtained using tools like Sematext Experience, which monitors Apdex score, optimizes Single Page Applications (SPA), and helps identify underperforming resources.
To improve FP and FCP, remove render-blocking scripts and CSS from the Head of your document, and use HTTP/2 server push to send necessary files to the client. TTI measures the time until the application is rendered and can respond to user input, while TTFB measures the time the first byte of each file reaches the user's browser. PRT measures the longest response time for all requests coming through the server, helping you identify performance bottlenecks. Hardware utilization, including CPU, RAM, and Disk space, should also be monitored to prevent performance issues.
Here are the performance metrics to track:
- Apdex score
- First Paint (FP)
- First Contentful Paint (FCP)
- Time to Interactive (TTI)
- Time to First Byte (TTFB)
- Peak Response Time (PRT)
- Hardware utilization (CPU, RAM, Disk space)
By tracking these metrics, you'll be able to identify areas for improvement and ensure a better user experience on your website.
Real-User Experience Data
Real-user experience data is a crucial aspect of measuring performance. It provides a glimpse into how real users interact with your website or application.
PSI reports real users' experiences over the previous 28-day collection period. This data is powered by the Chrome User Experience Report (CrUX) dataset.
To show user experience data for a given page, there must be sufficient data for it to be included in the CrUX dataset. If a page has recently been published or has too few samples from real users, it might not have sufficient data.
PSI presents a distribution of metrics so that developers can understand the range of experiences for that page or origin. This distribution is split into three categories: Good, Needs Improvement, and Poor, which are represented by green, amber, and red bars.
Here's an example of how PSI presents the distribution of metrics:
The 75th percentile for all metrics is also reported. This value is selected so that developers can understand the most frustrating user experiences on their site. These field metric values are classified as good/needs improvement/poor by applying the same thresholds shown above.
By examining the distribution of metrics and the 75th percentile value, developers can gain a deeper understanding of how real users interact with their website or application.
FP/ FCP
FP/ FCP is a performance metric that refers to the first pixels that are getting rendered after users access your website and how long it takes for the user to see them.
The difference between First Paint (FP) and First Contentful Paint (FCP) is that FP is the point when the browsers draw anything on the page, while FCP is the point where browsers start displaying pieces of content like text or images.
The most important parts of the website need to load first and fast. Google describes these parts as First meaningful paint (FMP) or hero elements and they need to be the priority.
To improve FP and FCP, remove any render-blocking scripts and CSS from the Head of your document. This will help your website load faster and more efficiently.
Identify the minimal set of styles you need to display the first important bits of your site. This will ensure that the most critical elements are loaded quickly, making a better user experience.
Using HTTP/2 server push on your app can result in incredible first paint times. This is because server push allows the server to send multiple files to a single client request, reducing the number of requests needed to load a page.
Here's an example of how server push works: when you load your index.html, the server can package necessary files like stylesheets or javascript files into one response, so they are already loaded by the time the DOM is parsed.
The following metrics are used to measure performance in the Performance category:
- First Contentful Paint
- Largest Contentful Paint
- Speed Index
- Cumulative Layout Shift
- Time to Interactive
- Total Blocking Time
Each metric is scored and labeled with a color-coded icon: green for Good, amber for Needs Improvement, and red for Poor.
Hardware Utilization
Hardware utilization is a crucial aspect of website performance that's often overlooked. It's up to you to keep tabs on your website's hardware, as it directly affects your website's performance.
You should prioritize monitoring three main components: the CPU, RAM utilization, and disk space. Any one of these components can create performance bottlenecks that can lead to catastrophic failures, such as shutting your entire server down.
Monitoring CPU usage is essential, as high CPU usage can cause your website to slow down or even crash. I've seen it happen before, and it's not a pleasant experience.
RAM utilization is another critical aspect to monitor, as running out of RAM can also cause performance issues. Make sure to keep an eye on your RAM usage to avoid any problems.
Disk space is also vital, as running out of disk space can cause your website to become unresponsive. Don't wait until it's too late – monitor your disk space regularly to avoid any issues.
Here are the three main components to focus on:
- The CPU
- RAM Utilization
- Disk space
Differences Between Psi and Crux Field Data
PSI's field data is updated daily, which gives you a more up-to-date picture of your website's performance.
The BigQuery dataset, on the other hand, is updated monthly and only includes origin-level data, which might not be as detailed as PSI's data.
Both PSI and BigQuery datasets represent a trailing 28-day period, so you can compare your website's performance over a consistent time frame.
This difference in update frequency and data depth can significantly impact how you analyze and improve your website's performance.
Tracking Effort
Tracking effort is a crucial part of measuring performance. It's essential to define how much time you will invest in an activity, such as studying JavaScript, and set a minimum amount of time you will dedicate to it.
To track time, use a time-tracker app like Clockify. First, define the activity and the time you will invest in it, such as 1 hour a day, 5 days a week. Second, create a project in the app to track the time spent on the activity. Third, start tracking time on the app. Fourth, periodically analyze the time tracking report to see how the activity is progressing.
For example, I spent 205 hours studying JavaScript during June, July, and August of 2021. This real measurement gives me a better feeling of the progress I'm making on JavaScript.
You can also track repetition, such as building a certain number of projects for a specific goal. For instance, you might decide to build 3 projects for your portfolio. Use an app like Notion to track the number of projects you're building, and this will give you a sense of advancing towards your goal.
Contents
There are several ways to measure website performance, and we'll cover some of the most important ones.
First Paint (FP) and First Contentful Paint (FCP) are performance metrics that refer to the first pixels that are getting rendered after users access your website and how long it takes for the user to see them.
To optimize FP/FCP, you can remove render-blocking scripts and CSS from the Head of your document. This will help your website load faster and improve the user experience.
Here are some key performance metrics to measure:
- First Paint (FP)
- First Contentful Paint (FCP)
- Peak Response Time (PRT)
Peak Response Time (PRT) measures the longest response time for all the requests coming through the server, giving you an idea of where your web application is underperforming or having difficulties fulfilling requests.
Sources
- https://pagespeedplus.com/blog/pagespeed-insights-localhost
- https://sematext.com/blog/website-performance-metrics/
- https://developer.mozilla.org/en-US/docs/Learn/Performance/Measuring_performance
- https://developers.google.com/speed/docs/insights/v5/about
- https://dev.to/colocodes/measuring-your-progress-in-web-development-why-is-it-important-and-how-to-do-it-55hj
Featured Images: pexels.com