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(early-hints): Add support for image early hint link tags #14827

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

damassi
Copy link
Member

@damassi damassi commented Nov 7, 2024

The type of this PR is: Feat

Description

Add support for image early hints (in addition to js, and other preconnects).

Additionally, refactors things slightly to remove the middleware and instead move the header assignment into renderServerApp, where its near our HTML generation.

Screenshot 2024-11-07 at 2 25 22 PM

cc @artsy/diamond-devs

@damassi damassi requested a review from a team November 7, 2024 22:28
@damassi damassi changed the title feat(early-hints): add support for images feat(early-hints): Add support for image early hint link tags Nov 7, 2024
Copy link

relativeci bot commented Nov 7, 2024

#881 Bundle Size — 9.53MiB (-0.16%).

bd96269(current) vs ffe4f84 main#484(baseline)

Important

Bundle introduced 1 and removed 4 duplicate packages – View changed duplicate packages

Warning

Bundle introduced 3 new packages: web-vitals, @sentry-internal/browser-utils, stylis – View changed packages

Bundle metrics  Change 9 changes Regression 1 regression Improvement 3 improvements
                 Current
#881
     Baseline
#484
Improvement  Initial JS 3.83MiB(-3.01%) 3.95MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 83.36% 2.04%
Change  Chunks 139(-2.8%) 143
Change  Assets 143(-2.05%) 146
Change  Modules 5665( 0.5%) 5637
Regression  Duplicate Modules 472( 3.74%) 455
Change  Duplicate Code 6.17%( 4.93%) 5.88%
Improvement  Packages 282(-3.09%) 291
Improvement  Duplicate Packages 39(-7.14%) 42
Bundle size by type  Change 2 changes Improvement 2 improvements
                 Current
#881
     Baseline
#484
Improvement  JS 9.3MiB (-0.1%) 9.31MiB
Improvement  Other 231.39KiB (-2.71%) 237.84KiB

Bundle analysis reportBranch damassi/feat/early-hints-imagesProject dashboard


Generated by RelativeCIDocumentationReport issue

@damassi damassi force-pushed the damassi/feat/early-hints-images branch 5 times, most recently from 997d086 to 8ca7582 Compare November 7, 2024 22:56
@@ -44,15 44,19 @@ export const renderServerApp = ({

const { WEBFONT_URL } = sharify.data
Copy link
Contributor

Choose a reason for hiding this comment

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

Oddly coming from sharify.data while above it's coming from process.env.

Copy link
Member Author

Choose a reason for hiding this comment

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

@dzucconi has a semi-mysterious comment up there so i didn't want to mess with any of those env imports

res.header("Link", [
`<${CDN_URL}>; rel=preconnect; crossorigin`,
`<${GEMINI_CLOUDFRONT_URL}>; rel=preconnect; crossorigin`,
`<${WEBFONT_URL}>; rel=preconnect; crossorigin`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Thought: Now that we're preloading js assets and fonts and a main image, I wonder if we even need these preconnects (that likely refer to the same domains). We can try removing them later.

src/html.ejs Outdated Show resolved Hide resolved
@damassi damassi force-pushed the damassi/feat/early-hints-images branch 8 times, most recently from 6068b8c to eaaf310 Compare November 8, 2024 04:54
@damassi damassi force-pushed the damassi/feat/early-hints-images branch from eaaf310 to bd96269 Compare November 8, 2024 06:08
@joeyAghion
Copy link
Contributor

joeyAghion commented Nov 8, 2024

If I understand correctly, this prescribes that components simply render fetchpriority attributes on <img>s, and that will automatically render <link> elements in the header and add Link: ... headers on the response.

  • If so, there are a few other places that render <link> elements explicitly. Should we drop those and make sure the <img>s have fetchpriority instead?
  • The regular expression seems to match any fetchpriority value, but I think it should only match fetchpriority="high". Our code sometimes outputs fetchpriority="auto"

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.

2 participants