Often, when creating single page apps, you need to populate the app with some form of data (i.e. in the json-format). This is usually done through an AJAX-call.
Now, this isn't the best possible solution. The DOM needs to be loaded before the AJAX call is launched, and it's semantically awkward to do this async through javascript.
Is it possible to load a JSON-resource in the same fashion as a <script src="some-file.js"> automatically fetches some-file.js, or fetches some-image.png automatically when the DOM loads?
Now, this isn't the best possible solution.I would argue that it is.The DOM needs to be loaded before the AJAX call is launched, and it's semantically awkward to do this async through javascript.I don't see how it's awkward. In jQuery, it can be as simple as 1 line of code.data = { "data"} ;?