MCPcopy Create free account
hub / github.com/DavidWells/analytics / isScriptLoaded

Function isScriptLoaded

packages/analytics-utils/src/isScriptLoaded.js:8–20  ·  view source on GitHub ↗
(script)

Source from the content-addressed store, hash-verified

6 * @return {Boolean} is script loaded
7 */
8export function isScriptLoaded(script) {
9 if (!isBrowser) return true
10 const scripts = document.getElementsByTagName('script')
11 return !!Object.keys(scripts).filter((key) => {
12 const { src } = scripts[key]
13 if (isString(script)) {
14 return src.indexOf(script) !== -1
15 } else if (isRegex(script)) {
16 return src.match(script)
17 }
18 return false
19 }).length
20}

Callers

nothing calls this directly

Calls 1

isRegexFunction · 0.85

Tested by

no test coverage detected