Git Product home page Git Product logo

jquery.lazyexecute's Introduction

jQuery.lazyexecute

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.

Usage

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();
});

Chaining

The plugin returns the given jQuery element for further usage.

$("#footer > .carousel").lazyexecute(function($carousel) {
  $carousel.jcarousel();
}).css("border", "1px solid red");

Minimize it

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

Credits

jQuery.lazyexecute is written on top of jQuery and is based on jquery_lazyload by Mika Tuupola.

License

Copyright (c) 2007-2012 Mika Tuupola

Licensed under the MIT license:

http://www.opensource.org/licenses/mit-license.php

jquery.lazyexecute's People

Contributors

andfx avatar baynezy avatar bryanchow avatar izzmo avatar joseprio avatar jpalardy avatar longlostnick avatar robwalch avatar silentmatt avatar tuupola avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.