Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add data-nuxt-img and data-nuxt-pic attrs #747

Merged
merged 3 commits into from
Mar 6, 2023
Merged

Conversation

kara
Copy link
Contributor

@kara kara commented Feb 15, 2023

This commit adds data attributes to usages of nuxt/image and nuxt/picture. This will allow us to compare performance results (in aggregate) for apps that use the components against apps that use normal <img> or <picture> tags. Currently, it isn't possible because there isn't a good way to distinguish the two in HTTP Archive.

Doing such a perf comparison allows us to:

  • ensure that these components actually improve performance
  • catch and fix performance regressions quickly

This commit adds data attributes to usages of nuxt/image
and nuxt/picture. This will allow us to compare performance
results (in aggregate) for apps that use the components
against apps that use normal <img> or <picture> tags.
Currently, it isn't possible because there isn't a good way
to distinguish the two in HTTP Archive.

Doing such a perf comparison allows us to:
- ensure that these components actually improve performance
- catch and fix performance regressions quickly
@netlify
Copy link

netlify bot commented Feb 15, 2023

Deploy Preview for nuxt-image-v1 canceled.

Name Link
🔨 Latest commit eff96f3
🔍 Latest deploy log https://app.netlify.com/sites/nuxt-image-v1/deploys/64020a91b60d64000868d726

@pi0
Copy link
Member

pi0 commented Feb 16, 2023

Thanks for pull request @kara! Since last time we discussed, adding data- attrs to all image components per page will add to the SSR HTML size for analyzes only. Do you think we can either:

  • Set a single flag to the HTML when image component is used
  • Only render it on client-side

Would be happy to discuss if you think still are merits to always include attrs to all components.

@kara
Copy link
Contributor Author

kara commented Feb 17, 2023

@pi0 After the last meeting, I did some digging in HTTPArchive and saw that the average number of images per page is ~20 images. Given that 13 chars * 20 is only ~260 bytes, it seemed like a reasonable trade-off for being friendlier to integration with dev tooling for users.

That said, we can do analysis on DOM properties as well, it's just a bit more work for us in HTTPArchive, so if you prefer client-side only, happy to update the PR.

@kara kara force-pushed the label branch 3 times, most recently from c7742b8 to 9f8a301 Compare February 17, 2023 00:43
@kara
Copy link
Contributor Author

kara commented Feb 17, 2023

@pi0 Thought about it more and realized that we can always switch to "data-" attributes if/when we decide to integrate with dev tooling, so we might as well do the slimmer, client-side option now. Just updated the PR to make it client-side only.

@danielroe danielroe requested a review from atinux March 4, 2023 15:14
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. LGTM. We can change strategy to more explicit dom if needed in next iterations.

@pi0 pi0 merged commit 9739e4d into nuxt:main Mar 6, 2023
@pi0 pi0 mentioned this pull request Mar 31, 2023
kara added a commit to kara/image that referenced this pull request Jan 26, 2024
Feature detection was added in nuxt#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.
kara added a commit to kara/image that referenced this pull request Jan 26, 2024
Feature detection was added in nuxt#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.
kara added a commit to kara/image that referenced this pull request Jan 31, 2024
Feature detection was added in nuxt#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.
kara added a commit to kara/image that referenced this pull request Jan 31, 2024
Feature detection was added in nuxt#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.
kara added a commit to kara/image that referenced this pull request Jan 31, 2024
Feature detection was added in nuxt#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants