rtCamp / rt-optimizer

A WordPress plugin that improves Core Web Vitals score by loading scripts via worker thread. Keeps the main thread idle for users to interact with page as quickly as possible.
GNU General Public License v2.0
20 stars 7 forks source link

Fix image sizes issue for LCP #25

Open pradeep910 opened 1 year ago

pradeep910 commented 1 year ago

Google pagespeed insights mostly gives issue for image sizes.

There is a good article here - https://danielbachhuber.com/solving-properly-size-images-wordpress/, which uses a tool to identify image sizes that need to be generated or fixed.

For more automation these are the things we can do:

pradeep910 commented 1 year ago

Thanks @Souptik2001 for pushing code to newspack.rt.gw, I can see "Link Images" option in admin bar, and also see failed and passed images. To further make it automated in terms of fixes, there is CLI script for generating images that we can run on ajax call for the sizes needed. https://github.com/wearetinybit/tinybit-core-plugin/blob/d85709769f2fe9d0e16db25205d7a51d46be5459/inc/class-cli.php#L40

Try using the following image sizes in instead: 256×173, 700×474, 1110×751, 1400×947, 1590×1076, 1760×1191

We might need a filter as well to convert output of image tag to use new sizes. Maybe everything we will have to do with image block render filter or the_content filter I think let's test it if it really works and improves LCP or not.

Todo:

pradeep910 commented 1 year ago

We have to hold this as the tool is not able to identify issues with images same as page speed insights. There is difference in page speed insights recommendations and this tool. https://ausi.github.io/respimagelint/

Ideally, we should have recommendations just like Page speed insights for a particular page in Query Monitor style output in footer.

I think the tool based on PHP or JS will be good. Maybe we can try using https://github.com/topics/google-pagespeed-insights some tools from this list. and log the results in Query Monitor style in footer.

cc @Souptik2001