jeudi 30 juin 2016

Loading image multiple times VS HTML elements?


I have a loop where a div element is created and inside that div an image gets printed. This loop goes on 14 times. So the same image and div gets printed 14 times. The image is 14KB. I have the ability to transform that image into an HTML element using divs, P tags, and CSS. Which is more efficient loading the same image 14 times or loading multiple HTML elements 14 times? If the browser caches that image, it wouldn't need to be downloaded 14 times because it's already downloaded. Would it still be more efficient to create that image using HTML elements and CSS? I am also working with PHP and MySQL, so if I switch to HTML the P tag that has to be printed out must be retrieved text from my database. So inside that loop that text must be retrieved 14 times as well if I switch to HTML.

Which is more efficient in my situation? Sticking to the image or changing the image into HTML elements with database retrieving?


Aucun commentaire:

Enregistrer un commentaire