Wednesday 15 January 2014

html - Many instances of one image on a page - does CSS background image perform better? -


If I want to show an image several times on my HTML page, which is better than the site's performance perspective, Many image tags with URLs, or many elements with same background image defined in CSS? The first way, the browser should cache the image for the first time, but there are still many requests to deal with it. On the other hand, I think there is only one request when CSS is parsed. Am I right in thinking that he is more efficient? "post-text" itemprop = "text">

In the case of CSS, too many background-image rules still make the browser a web request and & amp; Then caching the image Actually the same mechanics will be in place. The fact is that instead of HTML the images are referred to in CSS, the browser does not magically 'know', without it the image is without scrutiny of the cache.

The primary difference between your two scenarios, if you refer to all the images in the CSS, then CSS itself can be cached, which will represent minor performance improvements, And your HTML files should be small. Improvement or not enough - it depends on many other factors such as how many image references we are talking about, whether your HTML files are worth cache, how many pages-on average your user Make, and so on

Everyone said, CSS background image is a little better, but the reason is not that you are for the state. Whether you are saying HTML or CSS, you are still seeing a request after a group of cash-hits.

No comments:

Post a Comment