Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/notacouch/rloader
Automatically exported from code.google.com/p/rloader
https://github.com/notacouch/rloader
dependency-manager javascript lazyloading
Last synced: 8 days ago
JSON representation
Automatically exported from code.google.com/p/rloader
- Host: GitHub
- URL: https://github.com/notacouch/rloader
- Owner: notacouch
- Created: 2015-04-03T20:47:03.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-01-12T15:54:24.000Z (about 8 years ago)
- Last Synced: 2024-11-11T17:05:51.098Z (2 months ago)
- Topics: dependency-manager, javascript, lazyloading
- Language: JavaScript
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Loads resources like css and js files when you need them with one line of code.
It keeps track off the items that allready have been loaded.
If the same resource is called (loaded) twice it will load it only once.This is handy when you load pieces of content (widgets) with Ajax that needs the same resources. This form off loading items is also called **lazy** loading
and it can REALLY REALLY help you to speed up websites and webapplications.This plugin is very simple, but effective in use.. So Enjoy
# Usage #
## CSS parameters ##
* src: (string: the url to the css file)
* cache: (true or false) default: true (see the global settings)
* callback: (string or function) name of your function fired when loading is done
* arg: (string or JSON object) arguments, parameters for your callback function## JS parameters ##
* src: (string: the url to the js file)
* async: (true or false) default: true (see the global settings)
* cache: (true or false) default: true (see the global settings)
* callback: (string or function) name of your function fired when loading is done
* arg: (string or JSON object) arguments, parameters for your callback function
* excecute: (true or false) default: false, run the script itself e.g. even if cached already## Events ##
* event 'beforeload' Fired before the list gets loaded.
* event 'onready' Fired when every resource in the list is loaded (finished).> parameters:
> > func: (string or function) name of your function fired when loading is done> arg: (string or JSON object) optional arguments, parameters to parse to your callback function
## Making global settings ##
You can make global settings that rloader will use as a default for all resources.
When the parameters are omitted in the resources (css or js), the global settings will be used
as the default !* defaultcache: (true or false) default: true (so use browser caching by default)
* defaultasync: (true or false) default: true (so load it async by default)# Examples #
**Load 1 resource**
```
$.rloader({src:'/js/ctpgn.widget.min.js', callback:initwidget, arg:'MyArg'});
```> ---
**Loads 2 resources**
```
$.rloader([ {src:'/css/widget.css'},{src:'/js/ctpgn.widget.min.js'} ]);
```
_note: the default async and cache options will be used_> ---
**Loads 2 resources and fires an event when ready**
```
$.rloader([ {src:'/css/widget.css'},{src:'/js/ctpgn.widget.min.js'}, {event:'onready', func:'init_widget', arg:(parameters)} ]);
```
_note: the default async and cache options will be used_> ---
**Changing global settings**
```
$.rloader({defaultcache:false});
```