freeciv-web
freeciv-web copied to clipboard
"$ is not defined" in static/javascript
Thrown in both index.js as well as header.js Both seem to be plugins to jquery (correct me if I got that wrong) The error is not reproducible on my side.
Still jQuery should have been loaded before. Is this a race condition?
Waiting for the document to finish could fix this
$(document).ready(function () { ... }
Am I right?
I think you might be correct, it's worth a try.
I don't get it.
The error is supposedly thrown because $ is not defined in the global scope. How does a call to that same undefined function solve it?
But I don't get the error, either. jquery is executed before index.js and core.js, so it should be defined. Unless it couldn't be loaded, in which case you would always get two consecutive errors. I managed to reproduce that by routing jquery.com to the void.
But then those look like too many network problems for something like jquery. The net would be on fire...
And that wouldn't explain the cases in which only one error is thrown. I've only found those for the Baidu Browser, maybe it's somehow special, although it seems it uses the chrome engine.
And more importantly, nothing I'm saying includes a solution, I'm just blabbering :-(
I'm leaning more and more to a problem with loading https://code.jquery.com/jquery-3.1.1.min.js, be it timeouts, server overload, whatever.
For the game part a self hosted jquery is used, why not in the presentation page? If used like that to reduce load, how about something like https://stackoverflow.com/questions/1014203/best-way-to-use-googles-hosted-jquery-but-fall-back-to-my-hosted-library-on-go#9400432 so that jquery's copy is tried, but if unsuccessful, a local copy is loaded?
Feel free to improve this in a way you think is best. (My 2 cents: I suggest we use the self-hosted jquery everywhere).
@lonemadmax is there confidence this can be closed, based on the above commit, and trackjs data?
No. Still showing up, not only from header and index, but also from webclient. :man_shrugging: