Skip to main content

createScript

Tool for create and add scripts

Submit feedback
github
import { createScript } from '@uhg-abyss/web/tools/script';

Overview

The createScript tool simplifies creating and adding scripts to the document head. It takes in an id, src, and callback.

Usage

Example of setting a script link to a variable, and passing it into createScript. The script will then get added to the document head.

const scriptLink = 'https://examplescriptlink.com/script';
const callback = () => {
// Do something
};
createScript('unique-id', scriptLink, callback);

Properties

createScript(
id: string,
src: string || function,
callback: callback function
)
Table of Contents