mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-08 04:04:11 -04:00
24 lines
495 B
TypeScript
24 lines
495 B
TypeScript
export function scriptLoader(
|
|
id: string,
|
|
async: boolean,
|
|
src: string,
|
|
onload: (() => void) | null,
|
|
text: string
|
|
): void {
|
|
const s = document.createElement('script');
|
|
s.type = 'text/javascript';
|
|
s.id = id;
|
|
s.async = async;
|
|
s.onload = onload;
|
|
s.src = src;
|
|
s.text = text;
|
|
document.getElementsByTagName('head')[0].appendChild(s);
|
|
}
|
|
|
|
export function scriptRemover(id: string): void {
|
|
const script = document.getElementById(id);
|
|
if (script) {
|
|
script.remove();
|
|
}
|
|
}
|