-
Notifications
You must be signed in to change notification settings - Fork 140
add custom api for adding ttfmp from fragments #214
Conversation
Codecov Report
@@ Coverage Diff @@
## master #214 +/- ##
=======================================
Coverage ? 99%
=======================================
Files ? 15
Lines ? 603
Branches ? 112
=======================================
Hits ? 597
Misses ? 6
Partials ? 0 Continue to review full report at Codecov.
|
// Unique API that allows fragments to specify the | ||
// time to first meaningul paint of the page | ||
function addTTFMPEntry(duration) { | ||
addPerfEntry('ttfmp', duration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just keeping it as ttfmp
to avoid the name collision in future once first-meaningful-paint
is added to Paint Timing
👍 |
1 similar comment
👍 |
@@ -203,6 +211,7 @@ | |||
onAfterInit: assignHook('onAfterInit'), | |||
onDone: assignHook('onDone'), | |||
addPerfEntry: addPerfEntry, | |||
addTTFMPEntry: addTTFMPEntry, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think addPerfEntry.bind(null, 'ttfmp')
is shorter than the current implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bind is slow in older versions of v8 (older browsers might suffer from this). Thats why i went for explicit function. But, its just one time call so shouldn't matter much.
Why?
The previous API for adding performance entries to the page is pretty neat and already helps fragments to add custom timing information at every point of the render phase. But it lacks the uniformity and it will be pretty hard to use it for monitoring or any other purpose since the naming is quite different on every page.
Meaningful paint is different for each page and its hard to measure from tailor since tailor has no context of elements being rendered from fragments. Its best to keep the logic in fragments.
Solution
The current API is just a proxy to the old
Pipe.addPerfEntry
This API will be used only when primary fragments decide that the page is meaningful and the import part of the page is painted. It can be a Hero element that decides the meaningful paint of the page
Calling the API multiple times results in duplicate entries added to the Performance Entry. This is to keep in sync with PerformanceEntry Object
Future