async-content-loader
v1.0.5
Published
library for content management in browser environment
Downloads
1
Readme
Async-Content-Loader
Library for content managing in browser environment. It has no dependencies.
Install
npm install async-content-loader
How to use
globalContentLoaded - Promise
Waiting for content
import loader from '/node_modules/async-content-loader';
//Waiting for content loaded
loader.globalContentLoaded.then(function () {
//You will be here when all content loaded
});
loadLibrary({ path, id })
Load js script in head section with user defined id. The script with that id will be loaded only once. On second call it returns loaded script.
loader.loadLibrary({ path: '/test.js', id: 'Test'}).then(function (script) {
});
request({ path, option })
Request content from server
loader.request({ path: '/test.html').then(function (content) {
});
json({ path, options })
Request content from server in json format. The content will be parsed using standart JSON.parse method
loader.json({ path: '/test.json').then(function (content) {
});