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
- $.lazy([{
- src: 'jquery.elastic.js',
- name: 'elastic'
- }]);
- // And then you use you plugins as you always do
- $('textarea').elastic();
How to work with dependencies
- $.lazy([{
- src: 'ui.draggable.js',
- name: 'draggable',
- dependencies: {
- js: ['ui.core.js'],
- css: ['ui.draggable.css']
- }
- }]);
- // And then you use you plugins as you always do
- $("#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
- $.lazy([{
- src: 'ui.draggable.js',
- name: 'draggable',
- dependencies: {
- js: ['ui.core.js'],
- css: ['ui.draggable.css']
- },
- cache: true
- }]);
Caching is disabled by default, but you can enable it by setting the variable cache to true.
| Version | Changes |
|---|---|
| 1.5 | Refactored. (Thanks Kristofer Karlsson) |
| 1.3.1 | Critical bug fix for argument leakage. |
| 1.3 | Faster, better and stronger. Added cache control and a new API |
| 1.2.2 | Fixed a bug where Lazy would load the same plugin more than once. |
| 1.2 | Added support for jquery’s chainability |
| 1.1 | Added 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.
5 days ago
“CoffeeScript is Beautiful; Don’t Use It” My thoughts exactly. Thank you @ryanflorence! http://t.co/4bTAAIqE
5 days ago
“CoffeeScript is Beautiful; Don’t Use It” My thoughts exactly. Thank you @ryanflorence! http://t.co/4bTAAIqE
9 days ago
Looking for a solid way to do application versioning? Look no further. http://t.co/OMYJ2xzF Semantic Versioning guidelines are nifty!
11 days ago
The impossible is possible! http://t.co/Y4whjPIT Girl sneezes with open eyes.
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 )