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.

Upvotes: 5

Views: 358

Answers (1)

Moslem Shahsavan
Moslem Shahsavan

Reputation: 1337

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');

Upvotes: 2

Related Questions