Why not just wrap the decoded UInt8ClampedArray straight into a Blob of the appropriate bitmap mime-type and URL.createObjectUrl(blob) (making sure to appropriately URL.revokeObjectUrl on hash change or unmount) to create an image URL for a standard img tag (or anywhere an image source can be used such as CSS background-url)? It allows you more style options in CSS over the hash, and it makes it easier to swap in a real URL later when things have "loaded" without changing so many DOM elements in the process. Canvas seems like overkill for rendering the BlurHash in most scenarios to me, but maybe I'm missing something?
Blobs should be supported everywhere that UInt8ClampedArray is, so it doesn't seem like a compatibility issue to me.
https://caniuse.com/#feat=bloburls
https://caniuse.com/#feat=blobbuilder
Why not just wrap the decoded
UInt8ClampedArraystraight into aBlobof the appropriate bitmap mime-type andURL.createObjectUrl(blob)(making sure to appropriatelyURL.revokeObjectUrlon hash change or unmount) to create an image URL for a standardimgtag (or anywhere an image source can be used such as CSSbackground-url)? It allows you more style options in CSS over the hash, and it makes it easier to swap in a real URL later when things have "loaded" without changing so many DOM elements in the process.Canvasseems like overkill for rendering the BlurHash in most scenarios to me, but maybe I'm missing something?Blobs should be supported everywhere that
UInt8ClampedArrayis, so it doesn't seem like a compatibility issue to me.https://caniuse.com/#feat=bloburls
https://caniuse.com/#feat=blobbuilder