From: optimistx on 29 Dec 2009 06:04 How to measure, how much time there would be available for 'extra' javascript execution during page loading? How to utilize that time for calculations in js-language? SetTimeout? If yes, how? Ideas? (the question arose from the magic word 'efficiency': IF there is plenty of idle time during loading, why should one make less clear, difficult-to-read programs to have them more 'efficient')
From: JR on 29 Dec 2009 08:18 On Dec 29, 9:04 am, "optimistx" <optimi...(a)hotmail.com> wrote: > How to measure, how much time there would be available for 'extra' > javascript execution during page loading? > > How to utilize that time for calculations in js-language? SetTimeout? > If yes, how? > > Ideas? > > (the question arose from the magic word 'efficiency': IF there is > plenty of idle time during loading, why should one make less > clear, difficult-to-read programs to have them more 'efficient') I think this question is somewhat related to the window.onload problem, discussed in the thread 'DOM ready, window.onload, etc.': http://groups.google.com.br/group/comp.lang.javascript/browse_thread/thread/02b84e49fbe171c9/94225bbc33f9636f?hl=en#94225bbc33f9636f Cheers, JR
From: Hans-Georg Michna on 1 Jan 2010 15:04 On Tue, 29 Dec 2009 13:04:19 +0200, optimistx wrote: >How to measure, how much time there would be available for 'extra' >javascript execution during page loading? > >How to utilize that time for calculations in js-language? SetTimeout? >If yes, how? > >Ideas? Only a few vague ones. The first thought is that not much can be said reliable here, as every browser could do it differently. For example, most browsers stop other activities while JavaScript code is running, but Opera does it differently. Opera appears to intersperse load or render tasks in between JavaScript execution. I don't know the details. Another problem is that today's browsers handle all JavaScript code in single-threaded fashion, which means that your JavaScript code is pretty much at the mercy of the browser. You can't force any JavaScript code to run while the browser is doing something else. I don't know how the browser deals with incoming data while JavaScript code is running. Perhaps some browsers do more than one thing at the same time, but I'm not sure at all. Hans-Georg
From: David Mark on 1 Jan 2010 16:48 On Dec 29 2009, 6:04 am, "optimistx" <optimi...(a)hotmail.com> wrote: > How to measure, how much time there would be available for 'extra' > javascript execution during page loading? That doesn't make sense. Can you rephrase the question? > > How to utilize that time for calculations in js-language? SetTimeout? > If yes, how? > > Ideas? Same. > > (the question arose from the magic word 'efficiency': IF there is > plenty of idle time during loading, why should one make less > clear, difficult-to-read programs to have them more 'efficient') You seem very confused. There is no argument that says to write the most inefficient code possible (e.g. using jQuery) and neither is there one that says you should write everything to execute as efficiently as possible. It sounds like you are looking for an excuse to do something, but I don't know what that something is. What does the application do? What sort of agents will it need to run on? And are you proficient at code optimization (your name would seem to indicate that you are?) The first three rules of browser scripting are: context, context, context. ;) And, as an aside, there's nothing more difficult-to-read (or maintain or debug) than jQuery "sentences". That much should be obvious. I know that those raised by video games might think otherwise, at least those with no experience in reading programs of any kind. Memorizing patterns and mapping land mines is more video game than programming strategy. ;) But - for example - is this:- for (var i = 0; i < a.length; i++) ....really harder to read than:- for (var i = 0, l = a.length; i < l; i++) I put it to you that if it is, you are in the wrong business. Is the optimization worth it? Depends on the context. ;)
From: Osmo Saarikumpu on 2 Jan 2010 11:24
David Mark kirjoitti: > But - for example - is this:- > > for (var i = 0; i < a.length; i++) > > ....really harder to read than:- > > for (var i = 0, l = a.length; i < l; i++) Actually, it was. Confused the l for a 1 for a second there. > I put it to you that if it is, you are in the wrong business. I'm sure you are right there :) -- Best wishes, Osmo |