AH, I missed TAGs response (which is much more thorough) while typing mine - I like all of the suggestions :)
Tom On Aug 9, 5:38 pm, Tom Gregory <[EMAIL PROTECTED]> wrote: > On Aug 9, 2007, at 5:17 PM, [EMAIL PROTECTED] wrote: > > > > > So my original code sample was based on my application, which happened > > to use bindAsEventListener(). ... I > > originally said, but there still is a *serious* slowdown when I do > > Event.observe on IE6, and I'm not sure how to improve it. > > > This is still a bit rough, but my code is here if you want to see the > > exact example: > > >http://stage.whypaysticker.com/showroom/ > > Looks like a fun project. My suggestions (some are repeats from > earlier emails): > > 1. Don't use json.js. It conflicts with many other libraries. You > also don't need it--current Prototype versions have JSON support > built in. > > 2. You're still doing the binding inside the loop instead of > outside. Bind once, use the reference inside the loop. > > 3. I like the other Tom's suggestion re the onclick event observing, > although I'd take it a step further: observe only #carBrowser, not > each row. You can then use Prototype's findElement() function [a] > to zero in programmatically on which div was clicked. e.g. > Event.findElement(evt, 'div');, which should give you the div closest > (stepping up the tree) to the click location. This is what event > bubbling was created for! Take advantage of it. > a.http://prototypejs.org/api/event/findElement > > 4. The mouseouver/mouseout stuff really belongs in CSS (where it > would be wicked fast). I know IE6 has trouble with :hover unless > it's dealing w/ <a>, so that might require adding some <a> tags to > your markup ... but if speed is your primary concerns, I think it'd > be worth the trade-off. Even if you choose not to move it to CSS, you > could use a similar Event.findElement trick as suggested above, and > only apply the observer to the rows rather than the individual icons. > > 5. If speedup is your primary concern, use a reverse loop, not each > (). Each() is a great convenience method when speed costs are > negligible, but does have a small performance cost associated with it. > > http://home.earthlink.net/~kendrasg/info/js_opt/ > for (i = arr.length; i < 0; i--) { > > } > > 6. Instead of firing off an Ajax GET call immediately on page load, > load the correct content from the server the first time. > > 7. Append your many new elements to an element/document fragment > that's not part of the main DOM. Then attach it all at once. It'll > be faster than adding 'em to the main DOM one at a time. > > TAG --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
