0.0.4 • Published 7 years ago

deferred-scripts v0.0.4

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

deferred-scripts

Build Status Coverage Status npm

Defer <script> tag loading until needed.

If you have third party scripts you are unable to load until the user has given consent you can use this to defer them.

Installation

npm install deferred-scripts

Example

var deferredScripts = new DeferredScripts();

// addScript(sourceURL, onLoadCallback)
deferredScripts.addScript('https://www.google-analytics.com/ga.js', function() {
	// Onload
	console.log('Loaded GA')
})

// addPartial(sourceURL)
deferredScripts.addPartial('./my-partial.html')

// onLoadCallback is optional
deferredScripts.addScript('https://www.google-analytics.com/ga.js')

// When you're ready to load the scripts
deferredScripts.loadScripts();
0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago