Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One Image to Rule Them All: why Facebook and AddThis do that? [duplicate]

Possible Duplicate:
Single image file to store all the little images on a page

Hey,

Facebook are saving all the graphics on their page in a single image. So does AddThis. Why do they do that? How can I use the same techniques and cut the images with JavaScript?

like image 504
CamelCamelCamel Avatar asked Jan 21 '23 13:01

CamelCamelCamel


2 Answers

they are called CSS Sprites. It reduces the number of requests made to load the page, thus decreasing load time. The site can just set the background of something to be a small portion of the image.

like image 88
Scott M. Avatar answered May 08 '23 03:05

Scott M.


They do this so they can save connection overhead (otherwise browsers would open up a connection for every single image ~ if uncached).

You don't need javascript to cut up the image: use standard CSS positioning to show specific parts of the image.

like image 44
ChristopheD Avatar answered May 08 '23 03:05

ChristopheD