-
-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Well, this library is not SSR compatible, and there are only two reasons why not:
README
tells to add it to thehead
orbundle
, while it has to be inlined just afterbody
tag- it uses
onLoad/onError
handlers which are async
Let's make it work right!
Long story short - here is working sandbox - https://codesandbox.io/s/crazy-ganguly-hmhe8
- it inlines
base64 img
before the body to tell the browser about it. Theimg
is invisible. - it "checks"
img
synchronously after creating, and it does work! (only with a realimg
tag, preload does not help). - so it sets class to the body here and now, and the following HTML would use
webp
- as long as dataURI inlined in the same document - it does not affect gzip size.
Tested
In Chrome
(webp ✅), FireFox
(webp ✅), and Safari
(no webp, as expected)
Outcome
This library becomes SSR friendly!
Happy to open PR with a more compact version of the sandboxed example, however, the main changes are expected at the README level
Tom910
Metadata
Metadata
Assignees
Labels
No labels