Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out the time after which the item is rendered

How do I know after what time the button appeared on my site?

The site uses Angular.

I hoped to use npm lighthouse and user-timings for this task, but they are only for Js.

like image 607
Юрий Безруков Avatar asked Nov 07 '22 11:11

Юрий Безруков


1 Answers

use performance global object or test performance.now().

The Performance interface provides access to performance-related information for the current page.

console.time

This API is really easy to use. Simply put console.time before and console.timeEnd after the code you want to measure, calling the function with the same string argument. You can use up to 10,000 timers simultaneously on one page.

The precision is the same as of the performance API but this again depends on the browser.

console.time('test');
const len = 99 ** 2;
for (let i = 0; i < len; i++) {
  Math.sqrt(i);
}
console.timeEnd('test');
like image 130
Moslem Shahsavan Avatar answered Nov 12 '22 11:11

Moslem Shahsavan