What is Base64 and why it should be used to encode images?
Base64 is a group of encoding schemes to represent binary data in ASCII characters. Base64 is used, when binary data (such as images or video) needs to be transmitted over systems that are designed only to deal with data in a plain-text format. Encoding images with Base64 system help to avoid data corruption when shipping it across network. The process of encoding is done, by dividing binary data into 6-bit chunks and converting these chunks to the following 64 ASCII characters - 10 digits, 26 lowercase and 26 uppercase latin alphabet letters, + and / signs.
When Base64 encoded images are useful?
As the web grows more complex, web performance is becoming an increasingly important topic. One of the strategies to improve website performance is reducing the number of HTTP requests done for downloading first render resources. A separate HTTP request is sent for every image located on the web page. By using data URI, which contains Base64 encoded image content, image file can be embedded in HTML directly. So there will not be need to download an image and your website will speed up. However the wrong usage of data URIs can lead to performance lack for a number of reasons. So it is recommended to use Base64 encoding for non-big images (up to 1 MB) and not overuse them in web page.Learn more »