Severe jQuery lag on Firefox & Chrome, not IE though -
as stated in title, one-page site minimal jquery suffering crazy lag on chrome , firefox, not on ie10. realize ms stepped game 10, sweet lord's sake, deal?
i've read chrome laggy div hide()s , show()s, i'm using fadein() , fadeout(), , seems there's i'm missing.
i've created jsfiddle in case i've somehow done horrifically wrong.
http://jsfiddle.net/g2avityhitz/zdqed/1/
(function($){ $(document).ready( function () { $("#picbox .tiny img").click( function () { $("#picbox .tiny img").removeclass('selected'); $(this).addclass('selected'); imgsrc = $(this).attr('src'); $("#picbox .main").css({ 'background-image' : 'url(' + imgsrc + ')' }); $("#picbox .main a").attr('href',imgsrc); }); $("#picbox .main a").click( function (e) { e.preventdefault(); imgsrc = $(this).attr('href'); $("#lightbox .frame img").remove(); $("#lightbox .frame").append('<img src="' + imgsrc + '" />'); $("#lightbox").fadein(500, function () { $('#lightbox .frame .close').click( function () { $("#lightbox").fadeout(200); }); }); }); }); })(jquery);
please , thank you.
edit: great responses, point out again - no lag in ie, in chrome , firefox. behind this?
here example of caching optimize have.
will solve everything? not sure, things.
cached code:
var $images = $("#picbox .tiny img"), $main = $("#picbox .main"), $mainlinks = $main.find("a"), $lightbox = $("#lightbox"), $frame = $lightbox.find(".frame"), $frameimages = $frame.find("img"); $images.on("click", function () { var $this = $(this); $images.removeclass('selected'); $this.addclass('selected'); imgsrc = $this.attr('src'); $main.css({ 'background-image': 'url(' + imgsrc + ')' }); $mainlinks.attr('href', imgsrc); }); $mainlinks.on("click", function (e) { e.preventdefault(); imgsrc = $(this).attr('href'); $frameimages.remove(); $frame.append('<img src="' + imgsrc + '" />'); $lightbox.fadein(500, function () { $frame.find(".close").on("click", function () { $lightbox.fadeout(200); }); }); }); });
Comments
Post a Comment