kfirba
kfirba

Reputation: 5441

Usage of encoded images

Recently I found out about the encoded images (base64 strings) and it seems really nice. I have few questions about it:

  1. Should I make all of my images encoded?
  2. if I have a photo encoded, do I have to keep the photo on my website inside some directory?
  3. how much faster is this? does it really worth converting every image and use it as a string?
  4. 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?

Thanks in advance!

Upvotes: 1

Views: 67

Answers (2)

Mr. Alien
Mr. Alien

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

Fabrizio Calderan
Fabrizio Calderan

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

Related Questions