Champoo
Champoo is a lazy loader library. By separating conditioners & loaders, it gives you the flexibility to easily load pretty much everything, the lazy way... It is extensible & has a small footprint.
Installation
Node
yarn add champoo
or
npm install champoo
Browser
The package is available as a UMD module: compatible with AMD, CommonJS and exposing a global variable Champoo
in lib/Champoo.js
(less than 1Kb minified and gzipped).
Usage
;;; ; const champoo = conditioners: timeout: viewport: pointer: loaders: 'url': 'fb-comments': ; champoo;
Demo
git clone https://github.com/mawrkus/champoo.gitcd champoonpm installnpm run server:demo
Custom conditioners creation
A conditioner is a simple class having the following interface:
/** * @param * @param * @return */ { return { // call resolve() whenever the element meets the condition(s) // call reject() if there's a problem }; }
By registering it when instantiating Champoo...
const champoo = conditioners: amazing: loaders: // ... ;
...you can use it in the HTML:
Custom loaders creation
A loader is a simple class having the following interface:
/** * @param * @param * @return */ { return { // call resolve() when the element has been loaded // call reject() if there's an error while loading }; }
By registering it when instantiating Champoo...
const champoo = conditioners: // ... loaders: amazing: ;
...you can use it in the HTML:
Contribute
- Fork it:
git clone https://github.com/mawrkus/champoo.git
- Create your feature branch:
git checkout -b feature/my-new-feature
- Commit your changes:
git commit -am 'Added some feature'
- Check the build:
yarn run build
- Push to the branch:
git push origin feature/my-new-feature
- Submit a pull request :D