You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Data URLs are already URLs. You don't need to convert a data URL into an object URL to be able to use it. Doing that is slower, requires more code, and actually introduces a memory leak as URLs returned by URL.createObjectURL keep the blob alive until you call URL.revokeObjectURL. Instead, you can just use the data URL as the URL directly.
I ended up moving image generation logic back to server-side. The load experience is far better despite the larger payload size.
That's kinda sad. You can still try to reduce the image size and transfer a low res version, since the blur is somewhat forgiving in zoom blur. (also check out the other issue i linked)
Activity
Green-Sky commentedon Jun 20, 2024
The idea is to transmit the hash, not the image of the decoded hash. Assuming you are in fact generating them on the server.
lilouartz commentedon Jun 20, 2024
@Green-Sky Could you elaborate? I am not confident that I am following
Green-Sky commentedon Jun 20, 2024
It reads like you are rendering the thumbhash to png/avif on the server side and then send it as part of the html to the client.
What you really want to do, if you are not doing it, is send the thumbhash to the client and then run some js that renders the image on the client.
also this issue might be of interest to you: #33
lilouartz commentedon Jun 20, 2024
oh that was not obvious at all. hah!
Well, I need to update the article it seems.
lilouartz commentedon Jun 20, 2024
so, on the client side I would do something like this?
lilouartz commentedon Jun 20, 2024
This is what I have so far...
evanw commentedon Jun 22, 2024
Data URLs are already URLs. You don't need to convert a data URL into an object URL to be able to use it. Doing that is slower, requires more code, and actually introduces a memory leak as URLs returned by
URL.createObjectURLkeep the blob alive until you callURL.revokeObjectURL. Instead, you can just use the data URL as the URL directly.lilouartz commentedon Jun 23, 2024
The reason I used object URLs is to workaround this issue https://stackoverflow.com/q/78645289/24982554
lilouartz commentedon Jun 23, 2024
I am having a bit of a problem with this approach (of generating the image client-side).
It looks like the amount of time it takes to generate image makes the placeholder appear as a blank space for a long-time:
https://pillser.com/supplements/calcium-magnesium-zinc-with-vitamin-d3-2577
I even removed the
URL.createObjectURLlogic. It's now just:lilouartz commentedon Jun 23, 2024
I ended up moving image generation logic back to server-side. The load experience is far better despite the larger payload size.
Green-Sky commentedon Jun 23, 2024
That's kinda sad. You can still try to reduce the image size and transfer a low res version, since the blur is somewhat forgiving in zoom blur. (also check out the other issue i linked)
andupotorac commentedon Nov 30, 2024
@lilouartz this looks like something you need: #46.