-->

What are the drawbacks of base64 encoding data?

2019-07-18 04:58发布

问题:

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?

回答1:

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.



标签: base64