| http://peter-the-tea-drinker.com/pages/longjing-exmple.html Summary - if you don't want to break the web you should do this: 1. If you must use Javascript templating, inline the JSON into the document. 2. If possible, actually template the document too. Yes, single page apps are faster (because of the joke called javascript loading ... yes there's async, but it's broken, and you can load a script to load other scripts, but really ...). Except for when they load. Then there's a trip to your server, a trip to the CDN for the Javascript, then another trip to your server to get the document you wanted. Inlining the JSON saves 1 trip. Having the document already prepared saves another (since most browsers will render before the Javascript at the bottom). You won't notice running on localhost. It probably works ok on a good connection, if you're located in the same timezone. But with 200ms latency (on a mobile) and two round trips (plus your initial get) it makes a difference. And people using lynx or no-script won't tell you they can't read your site. For the ~80% of people who only visit your site once, this is close to optimal. You could trim it down a bit by querying your document, and building your data model from the static content, but that's just over engineering. |