4 ms·
Respectfully disagree with point 3 - "Doing unnecessary XHR requests on page load". It's better to have your main app page completely static so it can be cach
by zaius 14y ago
Respectfully disagree with point 3 - "Doing unnecessary XHR requests on page load".
It's better to have your main app page completely static so it can be cached. That said, don't use ajax either - load the initial data via its own script tag.
- SanderMak 14y agoDoesn't that also involve an extra HTTP call? I discussed the same issue as OP a while ago: http://branchandbound.net/blog/web/2012/11/unify-server-side-client-side-rendering-embedding-json http://branchandbound.net/blog/web/2012/11/unify-server-side... Someone in the comments there mentioned a nice alternative to embeddding the data in a <script> tag to avoid the problem jashkenas raised (</script> in the JSON). Namely, setting it in a data- attribute.
- Cthulhu_ 14y agoStill, optimizing the initial load is a good idea for applications like this. As an alternative, you could create an API service that returns all relevant information for the first page view in one block, instead of half a dozen smaller AJAX requests.