On 10/11/06, Chris <[EMAIL PROTECTED]> wrote: > While going through the MochiKit examples I realized I can use > MochiKit.Async to, as they say, "facilitate the 'half a second' live > updating". So instead of doing a call (or paring down) on each > keystroke just wait a 1/2 or 1/4 second. That might almost completely > solve my speed issue.
I have done this several times and the best solution seems to be that on each key-up, I set a timeout of about 200-500 milliseconds and store a reference to it. If another key-up happens before that, I cancel the first one and set another one. When the timeout fires, it makes the xhr call. > > JSON is much easier to work with than XML, but sometimes it's > > appropriate to just send HTML fragments since it is higher performance > > (but you trade client-side flexibility for that). Sometimes this > > decision depends what platform you're using on the server-side. > > I will be using LAMP. I'd definately suggest JSON if you're going to do some client-side processing on the data. There are libraries for PHP that convert plain PHP datastructures to JSON. That combined with loadJSONDoc means that you rarely have to worry about JSON - you just get your PHP datastructures "converted" straight to JS ones. > > In general, I'd suggest doing whatever is easiest to make correct > > first, and then optimize it for latency/performance later (if it turns > > out that you need to). > > That may be what I need to do. Keeping performance in mind from the start is always a good thing, but don't worry to much about it. I'm constantly surprised at how responsive things really are, given the complex round-trip of sending the request to the server, making the db call, retreiving and processing data, converting to json, sending the response and eval()-ing, more processing on the client-side and creating DOM objects on the fly. All happens in a split of a second in most cases :o) Arnar --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" 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/mochikit -~----------~----~----~----~------~----~------~--~---
