feat(loader): Make lazy-loading configurable#7232
Merged
AbhiPrasad merged 3 commits intodevelopfrom Feb 24, 2023
Merged
Conversation
mydea
reviewed
Feb 21, 2023
| var lazy = _lazy; | ||
| var forceLoad = false; | ||
|
|
||
| for (var i = 0; i < document.scripts.length; i++) { |
Member
There was a problem hiding this comment.
Just to be clear, we still want this to be overwritable by the script tag here:
Or should we guard that to be basically:
var lazy = _lazy;
// if lazy is set to false, we cannot opt in?
if (lazy) {
// check if option out of lazy
for (...) {}
} Just thinking, because I guess it would kind of break in the case of performance/replay if this were to be overwritten to true again?
Contributor
Author
There was a problem hiding this comment.
Just to be clear, we still want this to be overwritable by the script tag here:
Yup, the script tag always supercedes this. Here are the scenarios:
- lazy = true + data-lazy not set -> lazy == true (default for errors)
- lazy = false + data-lazy not set -> lazy == false (default for replay + perf)
- lazy = true + data-lazy === 'no' -> lazy == false
- lazy = false + data-lazy === 'no -> lazy == false
Member
There was a problem hiding this comment.
- lazy = false + data-lazy not set -> lazy == false (default for replay + perf)
but wouldn't this case, with the current code, lead to lazy == true? 🤔
Contributor
Author
There was a problem hiding this comment.
you're right 🤦 - I misunderstood the boolean condition ahhhhh
Let me change this
Contributor
size-limit report 📦
|
Lms24
approved these changes
Feb 24, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ref getsentry/sentry#44225
As per the work in getsentry/sentry#44876, make lazy loading a injectable option.
See https://docs.sentry.io/platforms/javascript/install/lazy-load-sentry/#load-timing for more details on how this works.