-
-
Notifications
You must be signed in to change notification settings - Fork 416
Add defer to script tag created by rollup build #1722
Conversation
|
By the way, why does the rollup build get such a strange way of including the script tag? |
|
It has |
Nope, it doesn't. Or at least the problem I'm running into is that if I have other script tags before editI'm reading about it now. I see that apparently it should infer In more detail, I'm loading firebase from a CDN and using So that to me implies that even though |
|
Hmm. MDN says "The defer attribute has no effect on module scripts — they defer by default.": https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script |
|
Okay so it's one of those terrible bugs that sometimes pops up and sometimes doesn't. But I'd like to invite you to go to this URL: https://mytryout-246d2.web.app/ Open up your console and refresh a bunch of times without cache (cmd+shift+R on a mac). Sometimes you'll get an error related to firebase and/or firestore. That is because of scripts not being run in the right order. Do you get that too? On my mac it happens both in Chrome and in Safari. editAfter more experimenting I found out that my change doesn't actually improve this erroneous behavior. I just thought it did, because this bug doesn't appear every time you refresh. |
|
Here's some video evidence of the issue. I'm not sure what to do with it. |
|
There's a perhaps related issue in #1725, but it was suggested there that this PR doesn't fix that issue. Does adding the |
|
@benmccann yes the onload handler does fix my issue. And yeah I was aware that my PR doesn't actually fix anything. It just seemed to, for a few minutes. 😅 editSo uhm, would it maybe be a good idea to apply that to sveltekit too? To put the sveltekit starter in a window onload event? |
#1123 added defer to the script tag when the bundler is not rollup. I think it was an oversight that it wasn't added to the other 2 lines.