Hacker News new | ask | show | jobs
by reissbaker 5048 days ago
Just one trick, although I use it in both the on and off demos to keep everything fair: I'm adding elements in smaller batches of 70 rows per tick of execution (arbitrary number), and then using a setTimeout to wait a few milliseconds before adding more. The demo loads a tooon of elements upfront -- much more than an ordinary site would -- and Firefox would sometimes complain if I loaded 400 rows of pugs at a single time. Chrome, of course, had no complaints, and IE was surprisingly fine as well.
2 comments

And from the comment above:

"...but because there are fewer elements in the DOM tree, relayouts are cheaper as well"

If I understand, this also applies? When I add the 400th (or whatever) ListItem it does trigger a layout when its added to the dom (to calculate its dimensions) but its much faster due to only having the currently viewable ListItems contained in the ListView?

Thanks again!

HN won't let me reply to your last comment -- nesting got too deep, maybe? -- but yup. Relayouts are less expensive as well.