Reputation: 5441
Recently I found out about the encoded images (base64 strings) and it seems really nice. I have few questions about it:
Thanks in advance!
Upvotes: 1
Views: 67
Reputation: 157334
Should I make all of my images encoded?
NO, some browsers have limit
From Mozilla Developer Network:
Although Mozilla supports data URIs of essentially unlimited length, browsers are not required to support any particular maximum length of data. For example, the Opera 11 browser limits data URIs to around 65000 characters.
If I have a photo encoded, do I have to keep the photo on my website inside some directory?
NO, you won't need the original image, if you encode it, than you will require that encoded string only.
How much faster is this? does it really worth converting every image and use it as a string?
It will save you http requests, and you shouldn't convert every image.
If I have a gallery, should I use the encoded images, or just keep it as it is which results in some cases in hundreds of HTTP requests?
NO, you shouldn't, take a look at lazy loading instead.
Upvotes: 2
Reputation: 123377
Should I make all of my images encoded?
Not necessarily. If you use a base64
encoding the size of the images grows typically by ~33%
than the original resources, they are not cached like regular images and they always need to be converted into images.
Thus it's better use this technique to reduce the requests amount for a few of small images. Besides, older browser like IE7
doesn't accept base64 encoding
I have a photo encoded, do I have to keep the photo on my website inside some directory?
No
how much faster is this? does it really worth converting every image and use it as a string?
No, see first answer
If I have a gallery, should I use the encoded images, or just keep it as it is which results in some cases in hundreds of HTTP requests?
I wouldn't recommend this. You should instead consider to use an image preloader or lazyloading
Upvotes: 1