Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can anyone with JS debugger experience (I am learning to fight the Chrome debugger now) tell me how to identify what is causing that terrible lag

Partly it would be nice to let the poor kid know, partly I want to know how to fix such issues as they inevitably crop up for me. (CPU measures seem not to point to anything useful)

(If the answer is take stuff away till it works, well, why have a debugger?)



I'm on my phone so all I can see is a jquery mobile-based site but, given some of the comments, I assume he's probably overloaded the scroll event. That event fires _a lot_ so if you load it up with too much logic or attach too many listeners, you get some nasty lag (think "New Twitter"). You're better off attaching a single listener that does some light action like setting a variable (`didScroll = true`) and an interval timer (every 50ms is fine) that checks that variable and performs some logic as a result.

John Resig wrote up an article about this very probably several years back. If curious, I can dig it up.


John Resig article circa jQuery 1.4.4 but still relevant: http://ejohn.org/blog/learning-from-twitter/


He's using the jQuery Waypoints plugin to fire events when a visitor scrolls to specified points on the page. Probably that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: