Bruce,
I ran into a minor head-scratcher updating an app from 11.47 to 12.47.
This is a "hybrid" app.
Much of it is pure NetTalk. But for reasons of imposed aesthetic choices, it has a section that displays pages formatted with Bootstrap. (They are patient status display pages on large monitors on the wall in various clinics. The status is updated every 15 seconds. A URL parameter hard-coded into the dedicated ChromeBox at each site tells the server which site's patients to display.) This was originally built in NT 10 and has been on NT 11 for the past couple of years.
Those pages are a NetWebPage "shell" that contains a framework of scripts and CSS and a named division.
One script is on a timer to update that named division by making a call to another NetWebPage every 15 seconds.
The scripts in the "shell" page are jquery and bootstrap (from the /scripts folder) and several scripts hard-coded in the NetWebPage. The latter are in the page rather than in a file because they include variables based on the URL sent to the page.
Then kaboom when I rebuilt with 12.47.
The reason turns out to be that you've added "defer" to NetWebServerWorkerBase.AddScript
That "defer" in the jquery loading then caused my locally-built scripts to throw an error - Uncaught ReferenceError: $ is not defined
What do you mean it isn't defined?? I just defined it!!! (Well, yeah.)
Anyway, now that I'm aware of the issue I've fixed my code in that one NetWebPage and all is well.
But I was wondering whether there would be any value in having an optional parameter to override that "defer" in NetWebServerWorkerBase.AddScript (or an overload version)?
Interestingly, looking at the NT history it says "Add: DEFER attribute added to all <script> sections. " for version
4.31(beta)And then again "Add: defer attribute to script files" for 12.09.
BTW - you generate
defer="defer"
The Mozilla docs say defer is Boolean.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-deferMy own experiment finds that just the presence of the single word
defer triggers the behavior.
As that Mozilla link says,
inline scripts without the type="module" attribute, are fetched and executed immediately,
So I need to un-defer the jquery rather than defer my inline scripts.
And that's how I spent my Sunday
Cheers,
Jane