MCPcopy Create free account
hub / github.com/boost-ext/di / loadScript

Function loadScript

doc/cppnow-2016/plugin/math/math.js:38–65  ·  view source on GitHub ↗
( url, callback )

Source from the content-addressed store, hash-verified

36 } );
37
38 function loadScript( url, callback ) {
39
40 var head = document.querySelector( 'head' );
41 var script = document.createElement( 'script' );
42 script.type = 'text/javascript';
43 script.src = url;
44
45 // Wrapper for callback to make sure it only fires once
46 var finish = function() {
47 if( typeof callback === 'function' ) {
48 callback.call();
49 callback = null;
50 }
51 }
52
53 script.onload = finish;
54
55 // IE
56 script.onreadystatechange = function() {
57 if ( this.readyState === 'loaded' ) {
58 finish();
59 }
60 }
61
62 // Normal browsers
63 head.appendChild( script );
64
65 }
66
67})();

Callers 1

math.jsFile · 0.70

Calls 1

finishFunction · 0.70

Tested by

no test coverage detected