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

Preload the image-set background images #6535

Closed
piotrbak opened this issue Apr 1, 2024 · 4 comments · Fixed by #6559
Closed

Preload the image-set background images #6535

piotrbak opened this issue Apr 1, 2024 · 4 comments · Fixed by #6559
Assignees
Labels
priority: high Issues which should be resolved as quickly as possible type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Milestone

Comments

@piotrbak
Copy link
Contributor

piotrbak commented Apr 1, 2024

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version
  • Used the search feature to ensure that the bug hasn’t been reported before

Describe the bug
As a part of 3.16 scope we need to preload the image-set background images when they're detected as LCP.

Expected behavior
Input:

background-image: image-set( "cat.png" 1x, "cat-2x.png" 2x);
background-image: image-set( url("cat.png") 1x, url("cat-2x.png") 2x);

or

background-image: -webkit-image-set( "cat.png" 1x, "cat-2x.png" 2x);
background-image: -webkit-image-set( url("cat.png") 1x, url("cat-2x.png") 2x);

Output:

<link rel="preload" as="image" imagesrcset="cat.png 1x, cat-2x.png 2x" fetchpriority="high">

Acceptance Criteria (for WP Media team use only)
LCP

  1. Images are preloaded using the image URL from the image-set declaration, they'll be added to the imagesrcset attribute
  2. fetchpriority="high" is added to the preload markup
  3. Images are excluded from LL Background Images feature

Above the fold

  1. Images are excluded from LL Background Images feature
@piotrbak piotrbak added type: enhancement Improvements that slightly enhance existing functionality and are fast to implement priority: high Issues which should be resolved as quickly as possible lcp labels Apr 1, 2024
@piotrbak piotrbak added this to the 3.16 milestone Apr 1, 2024
@piotrbak
Copy link
Contributor Author

piotrbak commented Apr 2, 2024

@DahmaniAdame @benorfaz There's also another background image-set to be handled:
-webkit-image-set

There's a possible edge case when image-set and -webkit-image-set are different images, then we'll preload both of them while without WP Rocket it'll load only one. I guess this is acceptable one.

CC @Mai-Saad

@Mai-Saad
Copy link
Contributor

Mai-Saad commented Apr 2, 2024

@remyperona
Copy link
Contributor

PHP part is handled for this case.

@Miraeld Miraeld self-assigned this Apr 15, 2024
@jeawhanlee
Copy link
Contributor

jeawhanlee commented Apr 15, 2024

Expected data structure in DB for LCP:

   {
     "type": "bg-img-set",
     "bg_set": [
       {"src": "cat.png 1x"},
       {"src": "cat-2x.png 2x"}
     ]
   }

Same will apply for ATF.

Miraeld added a commit that referenced this issue Apr 16, 2024
Preload `image-set` & `webkit-image-set`
@Miraeld Miraeld linked a pull request Apr 16, 2024 that will close this issue
14 tasks
Miraeld added a commit that referenced this issue Apr 17, 2024
Preload `image-set` & `webkit-image-set`
@piotrbak piotrbak closed this as completed May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high Issues which should be resolved as quickly as possible type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants