I am trying to improve my performance score on google lighthouse. It was recommending using next-gen image formats, including webp, so I implemented serving webp in place of images where the request accept header includes webp by using Nginx config something like this...
map $http_accept $webp_suffix {
default "";
"~*webp" ".webp";
}
server {
root /www/;
listen 80 default_server;
index index.html;
location ~* ^\/images\/ {
expires max;
add_header Vary Accept;
try_files $uri$webp_suffix $uri =404;
}
location / {
try_files $uri $uri/index.html =404;
}
error_page 404 /404.html;
}
Now the page loads much faster, and the webp method is working well, with fallback to original image where no webp exists or browser does not support it. However, the lighthouse report is showing an error, so I can't be sure I have implemented everything right. What does this error mean?
You can run it from within Chrome DevTools, as a Chrome Extension, or even as a Node module, which is useful for continuous integration. For a while now, Lighthouse has provided many tips for improving page load performance, such as enabling text compression or reducing render-blocking scripts.
The Lighthouse Chrome extension should automatically update, but you can manually update it via chrome://extensions. In DevTools, you can run Lighthouse in the audits panel. Chrome updates to a new version about every 6 weeks, so some newer audits may not be available.
Here is how to do it: Open Chrome and go to chrome://settings/content/javascript. Make sure the toggle next to Allowed (recommended) is turned on. Visit the website again to see if the images can be loaded normally. If not, try the next fix to turn off hardware acceleration.
Go to Network > Img and check the Status column. If the status code is 4xx or 5xx (e.g. 404, 403, 504, etc.), it suggests that the images not loading issues is more likely to be the website servers problem. If the there is no 4xx or 5xx status code on the status column, try Fix 2, below.
Update your lighthouse to version 2.4 onwards
On prior versions the webp extension was not handled correctly
https://github.com/GoogleChrome/lighthouse/issues/3364
If that's not working probably You might need to file an issue on Github
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With