Convert image to base64Converts an image to base64 for embedding HTML into a page or CSS.
Converting an image to base64 (data image base64) is sometimes needed to reduce the number of HTTP requests to the server. This is a good way to display icons on your site. In this case, the body of the image can be placed in the HTML-code of the page or in the CSS-file, where instead of SRC or URL you substitute the base64 code.
But you should understand that the base64 code weighs about 33% more than the file itself, so it is not recommended to display large images in this way.
But if you use base64 for icons or small pictures, then in some cases, in addition to reducing requests to the server, you can win in the final page weight. Because the server, in addition to the image itself, also gives back HTTP headers, which also have weight and are summed up with the weight of the image. And for an icon it can turn out that the sum of its weight and titles will be more than the base64 weight.
Base64 is a standard for encoding binary data using 64 ASCII characters. The coding alphabet contains text-numeric Latin characters A-Z, a-z and 0-9 (62 characters) and 2 additional characters depending on the implementation system. Every 3 original bytes are encoded with 4 characters, resulting in a 33% increase in data.