Skip to content

Commit 87e919c

Browse files
authored
feat(loader): Make lazy-loading configurable (#7232)
1 parent 21fb51b commit 87e919c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/browser/src/loader.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@
99
_namespace,
1010
_publicKey,
1111
_sdkBundleUrl,
12-
_config
12+
_config,
13+
_lazy
1314
) {
14-
var lazy = true;
15+
var lazy = _lazy;
1516
var forceLoad = false;
1617

1718
for (var i = 0; i < document.scripts.length; i++) {
1819
if (document.scripts[i].src.indexOf(_publicKey) > -1) {
19-
lazy = !(document.scripts[i].getAttribute('data-lazy') === 'no');
20+
// If lazy was set to true above, we need to check if the user has set data-lazy="no"
21+
// to confirm that we should lazy load the CDN bundle
22+
if (lazy && document.scripts[i].getAttribute('data-lazy') === 'no') {
23+
lazy = false;
24+
}
2025
break;
2126
}
2227
}
@@ -217,4 +222,4 @@
217222
}
218223
})(window, document, 'script', 'onerror', 'onunhandledrejection', 'Sentry', 'loader.js', '../../build/bundles/bundle.js', {
219224
dsn: 'https://[email protected]/1'
220-
});
225+
}, true);

0 commit comments

Comments
 (0)