Skip to content

seznam/IMA.js-plugin-script-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Seznam IMA.js plugin for loading 3rd party scripts

Resources

License

Stars

Watchers

Forks

Packages

No packages published