first is better. I mean, the top style will be most of the time != from 100px, so it will make more processing most of the times. first is better (again).
-- Fábio Miranda Costa Solucione Sistemas Engenheiro de interfaces On Thu, Dec 17, 2009 at 6:23 PM, Ryan Florence <[email protected]> wrote: > Assuming this is in a scroll event, so it gets fired a whole bunch: > > element.setStyle('top', 100); > > or: > > if(element.getStyle('top') != '100px') element.setStyle('top', 100); > > ? > > The first doesn't care, it just sets the style 100 times in a row. > > The second checks if it even needs to set it. > > So is the logic to find out more intense than just doing it anyway? I > imagine it is but I'm often surprised. > > Ryan Florence > > [Introducing MooDocs - become a better developer]( http://blog.flobro.com/ > ) > > > >
