What Are User Timing Marks And Measures?

User timing marks and measures are two performance-related features that are available in most modern browsers. They can be used to collect data about how your web page or app is used by your users, which can help optimize the performance of your website.

User timing marks are used to mark specific points in your code, which can then be measured by User Timing. This can help identify where bottlenecks are occurring in your code. For example, you could use a User timing mark to mark the start of a JavaScript file and then use a User timing measure to see how long it took for that file to load.

User timing measures measure the time between two User timing marks. This can help measure the performance of specific pieces of code. For example, you could use a user timing measure to see how long a particular AJAX request took to complete.

You can read more about user timing marks and measures on the W3C website.

What are user timing marks?

These two, user timing marks and measures, are performance metrics that can be used to identify issues and optimize web applications. User timing marks can measure the time between two events or the time to complete an event. User timing measures can measure the event duration or the number of events that occur in a given period.

How to add user timing marks?

Adding user timing marks and measures is a great way to get insights into your web pages’ performance. User timing allows you to track how long certain events will take on your pages, such as when a user clicks a button or link.

To add user timing marks and measures, you’ll need to create a new JavaScript file first. Then, you’ll need to include the following code in your file:

var startTime = Date.now();

function doSomething() {

  var endTime = Date.now();

  var timeTaken = endTime – startTime;

  console.log(‘It took ‘ + timeTaken + ‘ms for the function doSomething to run.’);


The code above will allow you to track how long it takes for the function do Something to run. You can also use this technique to track other events on your page. To do so, replace the function name in the code above with the name of the event you’d like to track.

Tips for marking time in your code

1. When you want to measure the time it takes for something to happen in your code, you can use the performance.now() method. This will give you an accurate timestamp to a thousandth of a millisecond.

2. You can also use the Date.now() method if you don’t need such high precision.

3. If you want to measure how long something takes in specific units (e.g., seconds, minutes, etc.), you can use the performance.mark() and performance.measure() methods.

4. Finally, if you want to get detailed about what’s happening in your code and how long it took for each part of it to run, you can use the User Timing API’s mark() and measure() methods.


The User Timing API is a great way to get insight into how your users interact with your web applications. By using marks and measures, you can track specific events and timing information to see where there might be bottlenecks or issues. In addition, the User Timing API can be used to collect performance data that can be used to improve the overall user experience.

Related Posts

Komal Bothra June 2, 2023

Google Bard Vs ChatGPT: Exploring The AI Chatbots Capabilities

Artificial Intelligence (AI) has revolutionized many industries, and one area where its impact is particularly

Komal Bothra June 1, 2023

How To Convert Sketch Design To WordPress Website?

Seeing the growing demand for WordPress development, businesses seek a reliable & well-versed WordPress development

Komal Bothra May 25, 2023

Best WordPress Development Agencies In 2023

According to recent statistics, WordPress has become a go-to platform for anyone who wants to


Get started with Seahawk

Sign up in our app to view our pricing and get discounts.