Skip to content

A simple library for caching js and css in localStorage's HTML5 API

License

Notifications You must be signed in to change notification settings

nimda95/cache-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cache-js.js

The localStorage cache for javascript and stylesheet libraries

Using the library is pretty simple

1. The Array object containing the sources

var resources = {
    onFinished: function() {
        // Callback to call when all files are loaded into the html page
	// [Suggestion] : Make this your window.onload()
    },
    files: {
        "unique name of the resource": {
            uri: "url to the file as it would be in the html page",
            version: "-",
            attributes: [{
                name: "name of the attribute",
                value: "value of the attribue"
            }],
            type: "style pr script"
        }
    }
};

Note: if the version is set to - the file will be always downloaded and never use the cached version

2. implementing the library

cacheJs.initialize(resources);

3. Recommendations

It is recommended to insert the above code directly into the html code as a script tag with the call for the library before it, instead of making another javascript file containing the above code.

About

A simple library for caching js and css in localStorage's HTML5 API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published