UPDATE: this solution is very hit or miss in how it works on older Safari browsers (so you can test this integration to see if it works for your needs
Hey all! I’ve seen a lot of people mentioning issues with older devices and browsers after converting their images to webp using the new Webflow feature. I ran into this with a client build and set out to find a solution and here it is with just a couple lines of custom code added to your global custom code settings!!!
Step 1: Go ahead and load these two scripts in your global site custom code
It says it’s converting .png on the fly, right in the browser.
There are a few known issues, though—importantly no CSS background image support!
Given that there’s no way to undo Webflow’s conversion, we better be darn sure everything is working reliably in real browsers (pre Big Sur Safari) before pulling the trigger. I’d strongly recommend testing on a special page hosting 1 or a few WebP images before converting the rest. (I guess I need to figure out which of my friends are still on macOS Catalina.)
EDIT: I suppose I could trust a test of a user-agent switch (to Catalina and older), by first making sure it doesn’t work without the script, then making sure it does work with it.
Okay so I did a “test test” to see if user agent spoofing is a reliable check… The result is negative, unfortunately.
I’m in Safari on the latest macOS Monterey. I loaded a page with one WebP (converted) image on it. It shows up (as it should) without implementing the script.
Then I switched my user agent (Safari menu bar: Develop > User Agent >) to Safari for iPad 13.1.3. The WebP image still loads (without implementing the script). According to "webp" | Can I use... Support tables for HTML5, CSS3, etc iOS Safari 13.1.3 should not support WebP.
So we can’t rely on user agent spoofing to test if this is working. (Correct me if you see anywhere I goofed.)
I know at least one person running Catalina, so I’ll check with them when I get a chance.
I have disappointing news about this fallback…
I implemented it to the best of my ability, and the first person I had test it for me was still not able to load the image in Safari on macOS Catalina.
Here’s what I did, in case you can spot a mistake:
I added both code snippets above to the global tag of one of my sites.
Had the Catalina Safari user clear cache and use a private browsing window to load the fallback test page I created (with a WebP image) using the webflow.io version of the site.
The page still showed up blank.
Thanks again for sharing this @austin, and please let me know if you see where I may have implemented this incorrectly.
For now, I think I’ll just be sticking with traditional image formats for a long while, still, or until Webflow can implement a native fallback.
(I must agree with others who’ve pointed out that a native-to-Webflow fallback really should have been implemented along with the release of this built-in conversion feature. Webflow’s own messaging on this strongly implies that WebP support is ready for prime time, just because the very latest browser versions support it. It’s naive to assume every visitor to your website is up to date on macOS. My clients’ analytics show that, indeed, they are not. I hope not too many Webflow users have pulled the trigger on this prematurely.)
Circling back to this it looks like it could be very hit or miss even down to the current page load on the site… So it’s not quite as foolproof as it appeared to be. Bummer
Could always plug-in the browser upgrade prompt — Catalina safari isn’t technically supported by apple anymore (annoying they tie browser updates to OS)