jQuery.lazyexecute allows you to lazily execute a function when an element appears on the browsers viewport. By lazily executing functions, e.g. binding events to elements in the footer, on JavaScript heavy sites, you are able to prevent the users browsers from "hanging" right after the page is loaded.
The plugin can for example be used to initialize a carousel as soon as the element, which wraps the carousel, is 200 pixels below the users viewport:
$("#footer > .carousel").lazyexecute(function($carousel) {
$carousel.jcarousel();
}, {
threshold: 200,
failure_limit: 0,
event: "scroll",
container: window,
skip_invisible: true
});
The options hash is optional and these options are the defaults.
So this does the same:
$("#footer > .carousel").lazyexecute(function($carousel) {
$carousel.jcarousel();
});
The plugin returns the given jQuery element for further usage.
$("#footer > .carousel").lazyexecute(function($carousel) {
$carousel.jcarousel();
}).css("border", "1px solid red");
curl \
-d output_info=compiled_code \
-d compilation_level=SIMPLE_OPTIMIZATIONS \
-d code_url=https://github.com/andfx/jquery.lazyexecute/raw/master/jquery.lazyexecute.js \
http://closure-compiler.appspot.com/compile
jQuery.lazyexecute is written on top of jQuery and is based on jquery_lazyload by Mika Tuupola.
Copyright (c) 2007-2012 Mika Tuupola
Licensed under the MIT license: