Scratch all that. I was loading dialog and testing hljs…
________________________________
From: Yishay Weiss <[email protected]>
Sent: Monday, May 18, 2020 9:09:45 AM
To: [email protected] <[email protected]>
Subject: RE: Script Loading Order (Continuing Heads-Up thread from Users)
Replacing
<script type="text/javascript"
src="./my.js"></script>
With
<script defer type="text/javascript"
src="./my.js"></script>
Results in network tab showing my.js loaded after dialog-polyfill.js, but I’m
still getting the same failure. It looks like at least for dialog stuff we just
need to be smart about when we use it, and check for the object being defined.
From: Yishay Weiss<mailto:[email protected]>
Sent: Monday, May 18, 2020 9:05 AM
To: [email protected]<mailto:[email protected]>
Subject: RE: Script Loading Order (Continuing Heads-Up thread from Users)
This code fails for me with and undefined hljs message:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.4.9/dialog-polyfill.min.js"></script<https://cdnjs.cloudflare.com/ajax/libs/dialog-polyfill/0.4.9/dialog-polyfill.min.js%22%3e%3c/script>>
<script type="text/javascript"
src="./my.js"></script>
</head>
<body></body>
</html>
my.js is
console.log(hljs.highlightBlock);
There are no generated scripts here. Network is again showing that my.js is
loaded after dialog-polyfill.min.js. Could it be that Chrome is prioritizing
local resources?
From: Alex Harui<mailto:[email protected]>
Sent: Monday, May 18, 2020 8:03 AM
To: [email protected]<mailto:[email protected]>
Subject: Re: Script Loading Order (Continuing Heads-Up thread from Users)
Every time I look, closure seems to change how it works. It looks like they
are using callbacks and UIDs. I assume they can't use await or Promise because
of IE support. I haven't looked at the code you generate, but might have to do
something similar, IOW, wait for the callback or known value before continuing.
I think that if we create the script during the running of another script that
we have to find a way to wait for that created script.
It might help to know what kind of initialization code needed the definition so
early. One alternative is that such code needs to be responsible for waiting.
Most of our Application classes have a wait mechanism. We could leverage that,
but that's also pretty late.
It could be that for Applications we generate the script in the head, and for
modules we generate a separate script that is preloaded.
HTH,
-Alex
On 5/17/20, 9:03 AM, "Yishay Weiss" <[email protected]> wrote:
>Is the script tag from inject_script going before or after the script tag
for the application (should be before, >IMO)?
It’s going before but the network shows it’s loaded after.
>Make sure the script tag has the same settings as the script tags google
closure uses in js-debug. I think they set some options so the scripts load in
order.
I see type being specified in the gcl script elements, while inject ones
don’t. I suppose it’s worth seeing if that makes a difference, though I
couldn’t find evidence for that on the web.