Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit b8f215a

Browse files
fix(bootstrap): disableScriptLoader to true still loads script
closes #235
1 parent bbefebd commit b8f215a

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/bootstrap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default () => {
1111
return
1212
}
1313

14-
const { disableScriptLoader: noScript, ready } = config
14+
const { ready } = config
1515
const filename = config.debug.enabled ? 'analytics_debug' : 'analytics'
1616
const resource = config.customResourceURL || `https://www.google-analytics.com/${filename}.js`
1717

@@ -26,7 +26,7 @@ export default () => {
2626
promisify(config.disabled)
2727
]
2828

29-
if (shouldGaLoad() && (!window.ga || !noScript)) {
29+
if (shouldGaLoad()) {
3030
queue.push(
3131
loadScript(resource).catch(() => {
3232
throw new Error (

src/helpers.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,18 @@ export function hasScript () {
5454
}
5555

5656
export function shouldGaLoad () {
57-
return !(config.checkDuplicatedScript && hasScript())
57+
const {
58+
checkDuplicatedScript,
59+
disableScriptLoader
60+
} = config
61+
62+
const requires = [
63+
Boolean(window && window.ga),
64+
(checkDuplicatedScript && !hasScript()),
65+
!disableScriptLoader
66+
]
67+
68+
return requires.some(Boolean)
5869
}
5970

6071
export function getTracker (tracker) {

0 commit comments

Comments
 (0)