diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-07-13 14:29:19 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-07-13 14:29:19 +0200 |
commit | f2d7195922bd72167f2a01ea10419296bc2e915a (patch) | |
tree | 4a29035f0353a9561660b5358b0374b6f84ed0a4 /geschichte/js/utils/loader.js | |
parent | chore(src/data/hello.sh): Remove (diff) | |
download | b-peetz.de-f2d7195922bd72167f2a01ea10419296bc2e915a.zip |
chore(geschichte): Remove
This is also irrelevant, as it is no longer used.
Diffstat (limited to 'geschichte/js/utils/loader.js')
-rw-r--r-- | geschichte/js/utils/loader.js | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/geschichte/js/utils/loader.js b/geschichte/js/utils/loader.js deleted file mode 100644 index 58d39ac..0000000 --- a/geschichte/js/utils/loader.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Loads a JavaScript file from the given URL and executes it. - * - * @param {string} url Address of the .js file to load - * @param {function} callback Method to invoke when the script - * has loaded and executed - */ -export const loadScript = ( url, callback ) => { - - const script = document.createElement( 'script' ); - script.type = 'text/javascript'; - script.async = false; - script.defer = false; - script.src = url; - - if( typeof callback === 'function' ) { - - // Success callback - script.onload = script.onreadystatechange = event => { - if( event.type === 'load' || /loaded|complete/.test( script.readyState ) ) { - - // Kill event listeners - script.onload = script.onreadystatechange = script.onerror = null; - - callback(); - - } - }; - - // Error callback - script.onerror = err => { - - // Kill event listeners - script.onload = script.onreadystatechange = script.onerror = null; - - callback( new Error( 'Failed loading script: ' + script.src + '\n' + err ) ); - - }; - - } - - // Append the script at the end of <head> - const head = document.querySelector( 'head' ); - head.insertBefore( script, head.lastChild ); - -} \ No newline at end of file |