Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Marl3x26765yYES
I have a prod problem that I cant eve debug because im at home and don't have a mac. -
Me: *programs website with webp images and uses moderizer to change them to png if the web browser doesn't support webp*
Chome: *loads webp*
Firefox: *loads webp*
IE: *loads PNG*
...
Safari: *fails to load the webp or the png even though the background-image is set correctly as it literally works in IE*
Safari = worse than IE -
@futurelucas4502 Sounds like you havn't used the "picture" tag?! You don't do browser detection, you let the browser choose instead.
-
@Fast-Nop it's a background-image so I can't really use the picture tag (everywhere it's not a background I am using a picture tag tho) and the code is definitely working as the background-image gets set to background.png and it works perfectly on IE but on safari it just doesn't load the image which is pretty cool
-
@futurelucas4502 One trick is to have a div with picture tag, set that to display:none and then get its current img src via JS, and use that to set the background. It's a bit of abusing the picture tag, but you get around browser detection pitfalls.
On the other hand, large background images where the difference between Webp and PNG would even be noticeable should probably not be used anyway. -
@Fast-Nop I hadn't thought of using a picture tag like that I may try it however I have been using moderizers webp tool its a JS script which will just detect if the browser has webp support or not then add webp or no-webp as a class to the html tag then u just set in ur css what u want the background to be accordingly however safari says no and its just annoying bc it even works in IE but I will definitely try using the picture method it's a bit jank but like if it works it works ig
Fuck Safari
rant