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

Twitter Bootstrap 2.0 is here. By nerds, for nerds. Cross everything. http://t.co/J4cFxGlb A neat looking front-end toolkit.

9 days ago

Looking for a solid way to do application versioning? Look no further. http://t.co/OMYJ2xzF Semantic Versioning guidelines are nifty!

15 days ago

On Amazon: Bad reviews are better for product sales than no reviews. (via @ronnestam )

15 days ago

There are only 180k Twitter users in Sweden, but ~75% of Sweden’s journalists use Twitter. (via @ronnestam )