• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Replacing jpg/png to webp and keeping compatibility

Explorer ,
Mar 17, 2024 Mar 17, 2024

Copy link to clipboard

Copied

Hello there. I have over 5k pages where each has at least one image with extension .png or .jpg. 

Now, I was checking my website performance here: https://pagespeed.web.dev/ and it shows my images load very long which gives low google score. 

 

They suggested to me to use webp files which is okay however, I have plenty of images. Do I really need to convert each image to webp and than brute force each .cfm file to edit HTML for each image. That would be crazy. 

 

Another thing here is that I would like to set that webp but still keep compatibility for browsers that don't support webp. That would probably involve using <picture> tag. 

 

But, my main question here is if there is something coldfusion can do about this to automate this so that I don't have to trouble myself with such robust job? 

Views

301

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 17, 2024 Mar 17, 2024

Copy link to clipboard

Copied

LATEST

To your last question, I think the answer will be no (about cf), but you can still do what you want without it.

 

1) First, cf does not currently support webp format in its various image processing tags/functions, so it can't be used to do that conversion. But of course many other tools can do that for you.

 

2) Second, as for changing the incoming requests from png or jpg to webp (once the images are converted), note that cf would never see those requests (as such static files are handled by your web server, like iis or apache).

 

But that's where you COULD change your image requests from one file extension to another, using a url rewrite. Too much to elaborate on here, and the steps are unique to each web server. And there are also reasons it may not work well for you, as a solution to this problem you present. 

 

Of course, you could just do a global find and replace in a decent editor, to change the image file extension references in your cfml. Just be sure to do a backup of your code before such a major change, in case you want to revert.

 

Others may have better ideas. I just wanted to start with some. 

 

(Also, beware to change a SAMPLE page first, to see if this suggested change to webp really solves the problem. It may not, in which case you'd not want to bother.)

 

3) There are indeed many other possible ways to speed up a site, again many having nothing to do with CF, so you may find still other solutions to consider, in your research. 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation