Prev: Earn Money from Home as Part Time Job!
Next: FAQ Topic - Why do I get permission denied when accessing a frame/window? (2009-12-27)
From: Hans-Georg Michna on 14 Jan 2010 18:09 By the way, how do you sort? Do you use JavaScript's array sort function? If not, you probably should, for higher speed. Hans-Georg
From: Hans-Georg Michna on 16 Jan 2010 06:48 On Sat, 16 Jan 2010 02:51:42 -0500, kangax wrote: >You might also be interested in: > ><http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/> I have some doubt here. The author writes under "Minimizing repaints and reflows", referring to DOM modifications through JavaScript: "• Don't change individual styles, one by one. …" But that looks like nonsense, as the browser will surely not reflow the document while the JavaScript code is still running, at least not while the same JavaScript function is still running. In fact, wouldn't it be wise for the browser to wait until all JavaScript processing has finished and the processor has nothing better to do? Hans-Georg
From: Jorge on 16 Jan 2010 07:21 On Jan 16, 12:48 pm, Hans-Georg Michna <hans- georgNoEmailPle...(a)michna.com> wrote: > On Sat, 16 Jan 2010 02:51:42 -0500, kangax wrote: > >You might also be interested in: > > ><http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/> > > I have some doubt here. The author writes under "Minimizing > repaints and reflows", referring to DOM modifications through > JavaScript: > > " Don't change individual styles, one by one. " > > But that looks like nonsense, as the browser will surely not > reflow the document while the JavaScript code is still running, > at least not while the same JavaScript function is still > running. > > In fact, wouldn't it be wise for the browser to wait until all > JavaScript processing has finished and the processor has nothing > better to do? reflow !== redraw (!) Say you've got: element.style.color= "red"; var height= element.offsetHeight; //won't reflow (except in IE :-)) But: element.style.fontSize= (a different value); var height= element.offsetHeight; //requires a reflow -- Jorge.
From: kangax on 16 Jan 2010 11:43 On 1/16/10 6:48 AM, Hans-Georg Michna wrote: > On Sat, 16 Jan 2010 02:51:42 -0500, kangax wrote: > >> You might also be interested in: >> >> <http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/> > > I have some doubt here. The author writes under "Minimizing > repaints and reflows", referring to DOM modifications through > JavaScript: > > "• Don't change individual styles, one by one. …" > > But that looks like nonsense, as the browser will surely not > reflow the document while the JavaScript code is still running, > at least not while the same JavaScript function is still > running. So if element dimensions change while function is running, what do you expect to see when inspecting that element's dimensions? Same value? For example: (function(){ var offsets = []; for (var i = 100; i <= 500; i += 100) { document.body.style.width = i + 'px'; offsets.push(document.body.offsetWidth); } return offsets; })(); Should `offsets` now contain same values? > > In fact, wouldn't it be wise for the browser to wait until all > JavaScript processing has finished and the processor has nothing > better to do? For repaint, sure, but not for reflow. -- kangax
From: Jorge on 16 Jan 2010 12:03
On Jan 16, 5:43 pm, kangax <kan...(a)gmail.com> wrote: > On 1/16/10 6:48 AM, Hans-Georg Michna wrote: > > > In fact, wouldn't it be wise for the browser to wait until all > > JavaScript processing has finished and the processor has nothing > > better to do? > > For repaint, sure, but not for reflow. Opera does -under certain circumstances- *redraw* in a separate thread, in parallel with JS execution. That's wiser imo, but a window.redraw() DOM method would be even wiser yet :-) -- Jorge. |