Created
May 30, 2016 18:31
-
-
Save woodphil/6bddb6f917eb0ae4d919fd544a5e426e to your computer and use it in GitHub Desktop.
Lazy loading for bootstrap's carousel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//not a perfect lazy load as it occurs on the slide event, not prior to the slide itself | |
$(function() { | |
return $("#carousel").on("slide.bs.carousel", function(event) { | |
var lazy; | |
lazy = $(event.relatedTarget).find("img[data-src]"); | |
lazy.attr("src", lazy.data("src")); | |
lazy.removeAttr("data-src"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment