Skip to content

Commit

Permalink
feat(loader): Make lazy-loading configurable (#7232)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad authored Feb 24, 2023
1 parent 21fb51b commit 87e919c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/browser/src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@
_namespace,
_publicKey,
_sdkBundleUrl,
_config
_config,
_lazy
) {
var lazy = true;
var lazy = _lazy;
var forceLoad = false;

for (var i = 0; i < document.scripts.length; i++) {
if (document.scripts[i].src.indexOf(_publicKey) > -1) {
lazy = !(document.scripts[i].getAttribute('data-lazy') === 'no');
// If lazy was set to true above, we need to check if the user has set data-lazy="no"
// to confirm that we should lazy load the CDN bundle
if (lazy && document.scripts[i].getAttribute('data-lazy') === 'no') {
lazy = false;
}
break;
}
}
Expand Down Expand Up @@ -217,4 +222,4 @@
}
})(window, document, 'script', 'onerror', 'onunhandledrejection', 'Sentry', 'loader.js', '../../build/bundles/bundle.js', {
dsn: 'https://public@example.com/1'
});
}, true);

0 comments on commit 87e919c

Please sign in to comment.