async-content-loader

1.0.5 • Public • Published

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) {
    
    }); 

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i async-content-loader

      Weekly Downloads

      3

      Version

      1.0.5

      License

      ISC

      Unpacked Size

      5.32 kB

      Total Files

      3

      Last publish

      Collaborators

      • millerrabin