WordPress / performance Public
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
Add low quality image placeholders #19
Comments
One thing to consider can be the Blurhash algorithm: Where the hash for the image can be stored as part of the meta of the image. |
The Node.js AMP Optimizer has support for blurry image placeholders. Here's the implementation: https://github.com/ampproject/amp-toolbox/blob/main/packages/optimizer/lib/transformers/AddBlurryImagePlaceholders.js |
The LQIP is quite a common pattern across the web now. I've worked on a few projects using https://github.com/aFarkas/lazysizes which also implements this paradigm. One way of handling the low quality image, in order to save a server request is to encode it: This means that theres no request to the placeholder image and the browser can carry on its business without worrying about connectivity or download issues. Im sure that may increase the byte size of the final HTML resource, but if sites are using |
I have implemented blurhash for the web stories plugin. I really liked it. I would be willing to work on this as a feature plugin. |
That looks promising, can the blurhash approach use the base64 version of the placeholder mentioned above? |
Did a bit of research on this @adamsilverstein - looks like its faster to run with |
Adding some additional ideas here in case we want to explore different alternatives:
|
One thing that we should remember is that images are indexed by search engines and one of the techniques to drive traffic to the site. If we replace images with placeholders, then this may cause images not being indexed by search engines and thus negatively affect the organic traffic for some sites. |
JPEG has progressive compression that allows to achieve similar results: https://medium.com/hd-pro/jpeg-formats-progressive-vs-baseline-73b3938c2339#e3aa Not sure how feasible it is to implement in our plugin. |
Possibly we could take advantage of this with custom Image classes, we need to look into support in libgd and imagick. This wouldn't help with WebP images. |
Good point that bears more investigation. Can the image(s) be listed in a meta tag to avoid that (ie og:image)? My other concern about this change overall is how it might negatively impact the largest contentful paint measurement, how much of a hit will that take for this "perceived" performance boost, and is that acceptable? |
I have looked at this a bit and a bit of code that works
I need to add a filter to the media.php in core
What I like about adding the image server-side is that don't have to wait for JS to render it but the downside is more data on the wire and isn't removed if no-JS (but we could handle that with CSS maybe) Would this approach work? I suspect that we will need a new filter for any approach we take to allow us to add elements to the img tags similar to this comint |
@pbearne Very interesting, I was wondering about using the background - clever!
Can you point specifically to where (or is there a ticket to add)? Could you try using Have you tested how this approach affects performance metrics? |
@eugene-manuilov Good point, this is a great feature of jpegs. When researching I found that LCP doesn't take progressive images into account currently (see w3c/largest-contentful-paint#71) so I'm curious how any approach would affect both perceived and measured performance. |
here is the filter I was looking at adding xwp/wordpress-develop@2efb39b
We are looking at the metrics it does add to the content on the wire so it may well be better to use JS to convert the blurhash into the background image |
@adamsilverstein I have a working(ish) plugin https://github.com/pbearne/blurhash |
Was looking for this all over! |
module for performance plugin |
Screen.Recording.2022-04-05.at.13.10.43.movvideo of it working |
interesting related ticket shared by Joy in slack: w3c/largest-contentful-paint#68 (comment) |
original conversation on slack As low-res image you can use the preview contained in the exif data of the jpg, a method to get that image is to use the function exif-thumbnail (php exif module needed). |
this also allows us to color the drop shadow |
adamsilverstein commentedNov 29, 2021
•
edited
The LQIP approach, popularized by Medium, uses a very small placeholder image to enable a quicker initial page load. The idea is the placeholder gives the user a sense of the image shapes and color while consuming minimal bytes. The hires image then replaces the placeholder later in the page load cycle.
The approach may help with perceived performance, although in general more bytes will be consumed overall - the extra image, plus the JavaScript to make the placeholder work. This approach deserves more research and might remain plugin territory.
previously: adamsilverstein/modern-images-wp#19
The text was updated successfully, but these errors were encountered: