Lazy

This Jquery plugin is an on-demand Jquery plugin loader, also known as a lazy loader. Instead of downloading all Jquery-plugins, you might or might not need, when the page loads. Lazy downloads the plugins when you actually use them.

Lazy is very lightweight, super fast, and smart. Lazy will keep track of all your plugins and dependencies and make sure that they are only downloaded once.

How to use Lazy

  1. $.lazy([{
  2.  src: 'jquery.elastic.js',
  3.  name: 'elastic'
  4. }]);
  5.  
  6. // And then you use you plugins as you always do
  7. $('textarea').elastic();

How to work with dependencies

  1. $.lazy([{
  2.  src: 'ui.draggable.js',
  3.  name: 'draggable',
  4.  dependencies: {
  5.   js: ['ui.core.js'],
  6.   css: ['ui.draggable.css']
  7.  }
  8. }]);
  9.  
  10. // And then you use you plugins as you always do
  11. $("#draggable").draggable();

This will load ui.draggable.css and ui.core.js before it loads ui.draggable.js and applies it on the element draggable.

Enable or disable caching

  1. $.lazy([{
  2.  src: 'ui.draggable.js',
  3.  name: 'draggable',
  4.  dependencies: {
  5.   js: ['ui.core.js'],
  6.   css: ['ui.draggable.css']
  7.  },
  8.  cache: true
  9. }]);

Caching is disabled by default, but you can enable it by setting the variable cache to true.

Release notes
VersionChanges
1.5Refactored. (Thanks Kristofer Karlsson)
1.3.1Critical bug fix for argument leakage.
1.3Faster, better and stronger. Added cache control and a new API
1.2.2Fixed a bug where Lazy would load the same plugin more than once.
1.2Added support for jquery’s chainability
1.1Added support for css and javascript dependencies

3 days ago

Wow! I don’t even remember anymore how I managed before this new awesome boilerstrap. http://t.co/bWzwqVf2

3 days ago

If you like coding and competing and want to see Stockholm at its best; Checkout Escape from /dev/null – DICE edition. http://t.co/0SapzZxz

5 days ago

Going where none has gone before and pushing the boundaries of what has been called done. Mine, @soe, @tussetor #SthlmStartupHack app ≈Done