-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
In the first paint example
/**
* Returns the browser's first paint metric (if available).
* @return {number} The first paint time in ms.
*/
function getFirstPaintIfSupported() {/* ... */}
// Take measurement after page load.
window.addEventListener('load', function() {
const fp = getFirstPaintIfSupported();
if (fp) {
const metric = new Metric('firstpaint');
//If I call log here
metric.log(); // I get firstpaint -1 ms
// No need to call start()/end(). Can send a value, directly.
metric.sendToAnalytics('load', metric.name, fp);
}
});Of course I can manually generate the log, but it could be nice if the log could take an overridable duration parameter (like sendToAnalytics):
log(duration = this.duration) {
console.info(this.name, this.duration, 'ms');
return this;
}Or maybe a way to set the duration itself for these types of events?
set duration(duration){
this.customDuration = duration;
return this;
}What do you think?
Metadata
Metadata
Assignees
Labels
No labels