ima-plugin-script-loader

0.14.5 • Public • Published

ima-plugin-script-loader

This is the plugin for loading 3rd party scripts for the IMA.js application. You can find the IMA.js skeleton application at https://github.com/seznam/IMA.js-skeleton or follow link https://imajs.io.

Installation

 
npm install ima-plugin-script-loader --save
 
// /app/build.js
 
var vendors = {
    common: [
        'ima-plugin-script-loader'
    ]
};
 
/*
Now is script loader plugin available as:
 
import { ScriptLoaderPlugin, events, defaultDependencies } from 'ima-plugin-script-loader';
*/
 

Usage

import Dispatcher from 'ima/event/Dispatcher';
import { ScriptLoaderPlugin, events as ScriptLoaderEvents } from 'ima-plugin-script-loader';
 
oc
    .get(ScriptLoaderPlugin)
    .load('//www.example.com/script.js')
    .then((result) => {
        console.log('Script is loaded.', result.url);
    })
    .catch((error) => {
        console.log('Script failed to load.', error);
    });
 
oc
    .get(Dispatcher)
    .listen(ScriptLoaderEvents.LOADED, (result) => {
        if (result.error) {
            console.log('Script is not loaded.', result.url);
        } else {
            console.log('Script is loaded.', result.url);
        }
    });
 

Package Sidebar

Install

npm i ima-plugin-script-loader

Weekly Downloads

2

Version

0.14.5

License

MIT

Last publish

Collaborators

  • jurca
  • mjancarik