migrated home.js and refactored into various sections
This commit is contained in:
parent
954507a20d
commit
67c1f520d8
13 changed files with 268 additions and 632 deletions
|
@ -1 +1,2 @@
|
|||
export * from './device';
|
||||
export * from './insertScript';
|
||||
|
|
14
assets/scripts/core/insertScript.js
Normal file
14
assets/scripts/core/insertScript.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
export const insertScript = (id, src, onload) => {
|
||||
// script is already inserted, do nothing
|
||||
if (document.getElementById(id)) return;
|
||||
|
||||
// insert script
|
||||
const firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
const scriptTag = document.createElement('script');
|
||||
scriptTag.id = id;
|
||||
scriptTag.onload = onload;
|
||||
scriptTag.src = src;
|
||||
scriptTag.defer = true;
|
||||
scriptTag.async = true;
|
||||
firstScriptTag.parentNode.insertBefore(scriptTag, firstScriptTag);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue