MCPcopy Index your code
hub / github.com/unconed/TermKit / loadScript

Function loadScript

HTML/syntax.js:42–70  ·  view source on GitHub ↗
(url, callback)

Source from the content-addressed store, hash-verified

40}
41
42function loadScript(url, callback) {
43
44 if (scripts[url]) {
45 return callback();
46 }
47
48 var script = document.createElement('script'),
49 done = false;
50
51 script.type = 'text/javascript';
52 script.language = 'javascript';
53 script.onload = script.onreadystatechange = function () {
54 if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
55 done = true;
56 scripts[url] = true;
57
58 // Handle memory leak in IE
59 script.onload = script.onreadystatechange = null;
60 script.parentNode.removeChild(script);
61
62 delete SyntaxHighlighter.vars.discoveredBrushes;
63 callback();
64 }
65 };
66 script.src = url;
67
68 // sync way of adding script tags to the page
69 document.body.appendChild(script);
70};
71
72/**
73 * Override highlighter to first load language-specific script.

Callers 1

syntax.jsFile · 0.70

Calls 1

callbackFunction · 0.50

Tested by

no test coverage detected