ima-plugin-script-loader

v0.13.0
Seznam IMA.js plugin for loading script
IMA.js Script loader Module Javascript

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

Metadata

  • MIT
  • Whatever
  • Miroslav Jancarik
  • released 7/11/2016

Downloads

Maintainers