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

Function loadScript

doc/cppnow-2019/reveal.js/plugin/math/math.js:33–60  ·  view source on GitHub ↗
( url, callback )

Source from the content-addressed store, hash-verified

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

Callers 1

math.jsFile · 0.70

Calls 1

finishFunction · 0.70

Tested by

no test coverage detected