Previous Entry Share Next Entry
11:37 pm, 10 Feb 05

evening hack

Evening hack: searchable Stranger valentines.

(per lazyweb request by joshc)

Update: a bit more on the "technology". I tried a few different approaches for making this fast. One important one was that the actual entries themselves were originally generated using innerHTML -- for the non-Javascript-savvy, you can assign to this attribute DOM nodes and the HTML you provide is parsed -- but this was slow (likely because of the parsing) and instead I create a prototypical element straightforwardly in the HTML and then clone it and modify its text to create the valentines themselves.

The other major bottleneck seemed to be filling the page with these nodes. I eventually capped it (because you don't really need more than 75 nodes anyway) but before that I tried some other things, including iterating through the list in reverse and repeatedly prepending rather than doing presumably the O(n^2) repeated appends.

I was also thinking of doing some fancy searching (in fact, my original idea involved using XMLHttp to have the processing done on a server) but when I tried the simple "search every entry" approach it appeared to be fast enough to work.