How can I create an environment in client-side javascript where any code related to user interface and views takes precedence over other code?
I know you can push things to next tick with setTimeout([function],0);
How could I build a system to do this on a widespread basis?
Javascript is single threaded (except for webworkers in the latest browsers) so you only have two options:
setTimeout(). This allows pending UI interactions to be done between each tick of non-UI work. This is a lot of work to code, but can be made to work if it’s really worth the effort.Here’s an example, I adapted from some other long-running code I had: http://jsfiddle.net/jfriend00/JJUgv/