First I want you to think that everything is RELATIVE and only experiences of each situation can determine CASE BY CASE which will perform better on your project and server.
There are two environments/layers that you have to think about, one is the rendering and the other the requisitions:
Front-End Rendering
Front-end rendering can begin to occur, even without the page being finished loading, that is, images can start loading and rendering even without the page having completed the download.
Thinking so the image being in Base64 issue, there may be two reasons that make it slower:
- The internal browser engine have to decode the image
- Base64 images using the protocol (data URI Scheme)
data:
increase the size of the html page by much, which makes the page slower than be rendered.
In conclusion, date protocol and Base64 can make rendering and downloading the html page slower, but you will save requests
Requests in the Back-End
Number of requests improve the performance, but not on the front-end side, but on the back-end side, that is, the fewer requests, probably the better performance, however in the case of the protocol data:
as I mentioned before, the html page will be bigger and then you can also have a new elevation on server consumption.
Keep-Alive connections
Browsers try to keep the connection open when requesting items from the same page, so if you have multiple images, the browser will probably try to decrease the connections (not the requests), which in a way would help. But note that it is not always possible to reuse the same connection and that the browser will behave exactly like this, each browser has its own way of doing this and will try to operate the situation as it sees fit.
Read more on: https://en.wikipedia.org/wiki/HTTP_persistent_connection
Completion
There is no way to state which will be faster, however I recommend you use static images with Cache and 304 Not Modified, see this question of mine:
Because this way you will have less impact on the server as to the static files, since the images will come from the cache in the next requests and will make the page download faster, this does not directly influence the rendering process, but I believe still images are "easier" to render to browsers than encoded ones.
I already used the second option, and the browser gave crash with very large image. So I made a method that recovered an image as Base64 and just call the same URL in your first example, it was the best way for a better user experience including.
– Giancarlo Abel Giulian
Wallace, I believe that putting this image as Base64 on all images can even slow the loading of the page. I believe the best thing about you is to pre-load this image using CSS, like adding the following line to your global CSS:
#preload-01 { background: url(http://link-da-imagem) no-repeat -9999px -9999px; }
, this way the image will have already been loaded by the browser before its use.– Tobias Mesquita
I don’t have all the necessary arguments to answer, but just say that Base64 does not generate cache, which is bad if you always have the same image for the page.
– Guilherme Lautert
Base64 is good for captcha.
– Guilherme Lautert
Great argument @Guilhermelautert, I had to use cache and called the image via URL even, worked smoothly, did not know that when Base64 does not store cache.
– Giancarlo Abel Giulian
Dear your question is interesting, and one day searching I found that google itself already shows us that can be a way yes. Do the following, type
goku imagens
on google, on the results page (do not go to the images page) see the short list of photos that will appear, if you see their property, Voce will see that they are in Base64– Skywalker
Good practice would be to use Base64 only for images smaller than 5KB, as suggested this article.
– HumbertoDONTEC