[jQuery] Re: help optimizing code

2008-01-19 Thread cjl
Karl: Thanks again. One last bug in the code you posted above, in the $ ('div.flag').each function, the assignment: var $this = $(this); Needs to take place before the if-else statements. Overall, you improved code runs in approximately 1 second...down from 4 seconds for my original code. Wow!

[jQuery] Re: help optimizing code

2008-01-19 Thread cjl
t;).before(""); $(".flag").each(function (i) { ... Also, TT, thank you, firebug is exactly what I was looking for! -CJL

[jQuery] Re: help optimizing code

2008-01-19 Thread cjl
script as I try to optimize it, to find out where the slow bits are? I'll give the setTimeout method a shot. If that will let the page render before running the javascript, the delay won't be so bad. -CJL

[jQuery] help optimizing code

2008-01-19 Thread cjl
iding the JSON). 2. eval the JSON data into a variable. 3. crunch the JSON data into an array, so that I can figure out which comments apply to which paragraphs 4. for every paragraph in the document add a div before and after 5. fill in the number of comments into the appropriate "flag" div, and the comments into the "comment" div The script works, but it is slow for 109 paragraphs. Any suggestions to speed things up? The main problem I see (Firefox, Windows XP) is that the page does not display at all until the javascript finishes processing. Is there a way to display the page first, then run the javascript? Maybe I could center a div that says "loading comments" and hide it after the comments load, but as things stand the browser freezes for 5 or so seconds. Help? Thanks in advance, CJL