60fps scrolling using pointer-events: none
thecssninja.com
thecssninja.com
This is because I'm not sure if, since -94 or so, I've seen a single case where event handling while scrolling would have actually added to browsing usability at all. It consistently creates two kinds of problems: first laggy scrolling as elements with heavy events handlers get focused and unfocused and secondly crazy behaviour when on-hover menus will open abruptly while scrolling and the state of the page ends up messed up when the scrolling stops.
It makes sense to scroll like it happens in mobile devices: the input events drive the scrolling only and the page just pans around as long as the fingers move on the screen, and the browser effectively returns to interactive mode when the scrolling stops.
This is probably a useful technique for specific situations where scroll events are causing issues, but it's definitely something that should generally be handled by the browser, rather than the developer. Still, Safari's awesome performance suggests that there's room for improvement in browsers' handling of this situation.
Works on all pages, just adds the pointer-hover: none to the body element. Using modified code from the article. Quite useful, really. I'm surprised at how often I subconsciously guide my cursor away from content while scrolling pages to prevent hover effects popping off.
Also I'd guess that this is an area that's only recently been necessary to optimise in browsers.
_______
¹ Fun fact: It's a lot faster in IE than in Chrome ;-)
There's probably a tradeoff between the time it takes to set up those data structures, the time they'd save, and the time it takes to handle the pointer and hover events without them. Maybe it's not worth it.
Memory consumption would also be an issue.
The excuse I hear from people who understand this stuff properly is that the quake engine didn't need to have a top of the line text rendering engine running on every surface, and this is what makes visual effects in browsers so expensive.
Instead if you build an abstraction layer on top of the DOM that only exposes fast primitives you'll be better off.
On the other hand, it handled just that. No dynaming styling, no CSS, no DOM, ...
I believe the official system requirement was a Pentium 75, though in reality you could run it on a 486DX pretty well if you had a VESA local bus video card, etc.
(I think I remember running it pretty horribly on a 486SX, like 3fps...)
Oh, the memories!
[1] http://www.thecssninja.com/javascript/pointer-events-60fps/c... [2] http://www.thecssninja.com/javascript/pointer-events-60fps/c...
I want to subscribe to their articles, Twitter? No, Google Plus? No,... they only have RSS.
Now I wish there was a Google product that works with RSS.
* the browser can implement this optimisation
* spatial partitioning maybe is a much better general solution. the 2d aabb case is extrememly fast and can handle checks against 10000s of boxes per ms with good memory layout
* stagger checks across frames if more optimisation is needed when there are say, 100000s boxes to test (maybe? i'm skeptical even that would be especially slow)
Perhaps the demo "paints" a false picture considering that most sites don't have the same simplicity/symmetry of hoverable elements.
[a isNotEqualToIntegerWithSign:b]
(a parody of course)