Reputation: 15506
some time ago I bought a gallery script online. Back in those days I had never heard of 'too many http request' let alone of 'sprites' and their immens power to improve speed! I guesse the original author, too, was not familiar with sprites... Now I do and would like to customise that script for my site, and change all the instances where png is loaded, by sptires. I know how to do this in CSS, with background position offsets, but not how to make it happen in javascript.
My question is: 1) How is conversion from direct url http://.../etc.png towards a sprite loading PNG done? 2) It looks like asif the PNGs are not consistently referred to below. How can I cope with this when making everything consistent from a single sprite? Thanks very much! Any help that gets me going is much appreciated.
Notes to Self: all the occuring instances of PNG in entire script:
LINE|====================IMAGE===================================================
118 | $mainImg = $("<img id='main-img' src='http:///spacer.png'/>");
135 | var $backBtn = $("<img src='" + LIGHTBOX_PATH + "prev.png' id='back-btn'/>");
138 | var $fwdBtn = $("<img src='" + LIGHTBOX_PATH + "next.png' id='fwd-btn'/>");
141 | var $closeBtn = $("<img src='" + LIGHTBOX_PATH + "close.png' id='close-btn'/>");
150 | $playBtn.attr("src", "http:///pause.png");
153 | $playBtn.attr("src", "http:///play.png");
163 | $textBtn = $("<img src='" + LIGHTBOX_PATH + "info.png' id='txt-btn'/>");
229 | $(this).attr("src", "http:///spacer.png");
303 | .attr("src","http:////spacer.png").animate({opacity:1}, tranSpeed, startTimer);
353 | $playBtn.attr("src", "http:///pause.png");
357 | $playBtn.attr("src", "http:///play.png");
776 | $prevBtn.css({"background-image":"url(http:///prev.png)",
779 | $nextBtn.css({"background-image":"url(http:///next.png)",
Upvotes: 0
Views: 1205
Reputation: 3887
For all of the references above:
For each css class defined in 1 above:
Note: These classes can generally be created for you using a sprite creator program. (http://spritegen.website-performance.org/)
If everything went well:
Upvotes: 1