Over the past two years or so, I've base64 encoded multiple types of data for the web: images, .otf
files, text, and so on. It's practical in that it serves as a makeshift asset consolidation method (with the data embedded directly in the CSS or HTML, one doesn't have to worry about a dead link), but are there any drawbacks to using this method?
Asked
Active
Viewed 3,289 times
3

Jules
- 14,200
- 13
- 56
- 101
-
1Advantages asked here http://stackoverflow.com/questions/1682949 – Val Jan 19 '13 at 21:12
1 Answers
8
The base64 encoded data is about 33% larger than the raw data.
Another effect is that you are bundling several pieces of data together into larger chunks. Sometimes this is a positive effect, sometimes negative. Requesting fewer resources is positive, but only if the resources have the same caching status. If you for example bundle an image in an HTML page, the image can't be cached separately as it has to be fetched every time the HTML page is fetched.

Guffa
- 687,336
- 108
- 737
- 1,005
-
-
@MehdiKaramosly: What kind of streaming? The method that the OP talks about embeds the resource in the HTML document, so that's the opposite of any kind of streaming. – Guffa Nov 20 '13 at 00:06
-
that is out of topic, I am talking about my case which is sending printscreens (screen sharing app) and wanted to know if that is a nice idea to use Base64 ? – Mehdi Karamosly Nov 20 '13 at 00:21
-
@MehdiKaramosly on the off chance that you're still caught up on that after a few years, no, it's not. Depending on your application, you may want to look into either WebSockets or AJAX polling. – Jules Sep 20 '17 at 13:41