-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update feature detection markers to match new standard
Feature detection was added in #747 to allow performance analysis for nuxt/image uses in aggregate. Since that time, Javascript-based feature markers have been standardized in the W3C group around the User Timing API: https://www.w3.org/TR/user-timing/#dfn-mark_feature_usage This commit updates the feature tracking to use the new standard, which is designed to be performance-neutral. The previous mechanism (the data- attributes) will be removed in a future PR, once we can confirm it works as expected end-to-end.
- Loading branch information
Showing
3 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Feature detection enables us to analyze the performance of nuxt/image | ||
* usages and validate performance outcomes (in aggregate only). | ||
* | ||
* Javascript-based feature markers have been standardized in the W3C group | ||
* around the User Timing API. See more detail here: | ||
* https://www.w3.org/TR/user-timing/#dfn-mark_feature_usage | ||
*/ | ||
export function markFeatureUsage(featureName: string) { | ||
performance?.mark?.('mark_feature_usage', { | ||
detail: { | ||
feature: featureName | ||
} | ||
}) | ||
} | ||