3 ms·
- Preload html view on page load (saving another extra roundtrip!) does this mean it serves fully formed html like rendr[1] or highbrow[2]? I'm not sure what
by bryanlarsen 12y ago
- Preload html view on page load (saving another extra roundtrip!)
does this mean it serves fully formed html like rendr[1] or highbrow[2]? I'm not sure what angular does, but all client-side apps I've seen, templates are compiled into javascript and concatenated onto the app code, so they're never an extra roundtrip.
1: https://github.com/rendrjs/rendr https://github.com/rendrjs/rendr
2: https://github.com/wvl/highbrow https://github.com/wvl/highbrow
- SDGT 12y agoDepends on how you're using angular to inject views. Vanilla angular views are requested, parsed, bindings added, and then presented. It's one request for the html, all the rest happens in browser. angular ui views may be different, but according to my network panel on chrome its still one request for the template and whatever assets it brings with it. I'm going to guess the guys meant they will preload the first view based on page state, which does indeed save a single round trip, but means nothing for any state changes that would occur after the fact. I would argue that an app which needs to micro optimize like this might not be built correctly from the get go, as you're really only saving 1 request and whatever small byte size of the content.
- KaoruAoiShiho 12y agoYour response to someone making an amazing optimization is if you need optimizations your app is done wrong... seriously? You're seriously underestimating the difference this makes. If this is rendr for angular it is a breakthrough for the angular community.
- benaiah 12y agoThat's not what he said. He said it probably wasn't rendr for angular. I'm pretty sure he's saying they preload the initial viewing template (not a prefilled template) based on app state - stuff like clientside routing and such. The browser still has to render the template, but it doesn't have to be fetched by a separate request.
- KaoruAoiShiho 12y agoThat's true I don't see any examples of server side rendering though the developer says it works... https://github.com/JonAbrams/synth/issues/35 https://github.com/JonAbrams/synth/issues/35
- conradfr 12y agoPersonally with AngularJS I tend to embed multiple views with <script type='text/ng-template' id='hackernews.html'> </script> And you can call one view with your usual "templateUrl: 'hackernews.html'" Especially if I have many directives with more than a few lines of html. That way you can embed them in your main html or in a separate cacheable file.