4

I've noticed some "choppy-ness" when loading a component for the first time, especially when it's at the top of the page (as everything underneath it has already rendered). Come to find in the Knockout Documentation that the component loaders supply the view-model factory and template asynchronously.

Since application I'm currently working on is pre-compiled, is it possible to write a custom loader that will supply everything synchronously?

1 Answers1

3

No, it's not possible. Although you can set up a component loader that gets the component info synchronously, Knockout's component code will still render it asynchronously.

Michael Best
  • 16,623
  • 1
  • 37
  • 70
  • It only seems to render asynchronously the first time. Every other time after that it seems to be synchronous, is that right? Is this an issue with knockout using require.js to load the module? Looking at the knockout documentation here (http://knockoutjs.com/documentation/component-loaders.html#note-integrating-with-browserify) Browserify offers an alternative to asynchronous resolution but I'm unsure of how that works exactly. – James Chadwick Aug 20 '14 at 19:38
  • 2
    Any time a component is "loaded" and rendered, it's done asynchronously. Updates to binding and such within the component will be synchronous. – Michael Best Aug 20 '14 at 19:46
  • So the more we "componentize" our UI, the "jerkier" it renders. That is a really unfortunate side effect. Do the 'browserify' notes at the bottom of the documentation come into play here? http://knockoutjs.com/documentation/component-loaders.html – Shaun Rowan Aug 20 '14 at 20:24
  • I don't know about "jerky", but you would see component parts display slightly after other parts. – Michael Best Aug 20 '14 at 21:08
  • FYI created feature request here: https://github.com/knockout/knockout/issues/1504 . Perhaps this just isnt an issue many people care about (I think a web app should render either all at once, or top to bottom. "random order" is just wrong! :) or perhaps our application is just more impacted than others... – Shaun Rowan Aug 27 '14 at 23:04