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.