BrowserSync / browser-sync-client

Client Scripts for BrowserSync
MIT License
43 stars 46 forks source link

Browser-sync blocks thread when scrolling #37

Open callumacrae opened 7 years ago

callumacrae commented 7 years ago

Related: https://github.com/BrowserSync/browser-sync/issues/1203

browser-sync seems to phone home on every single scroll event, even when ghost mode is disabled. While this may seem like a useful feature for debugging scroll stuff on multiple devices at the same time, it actually does exactly the opposite: it blocks the thread for 5-10ms, lowering the FPS further on poorly performing apps (and making it super difficult to debug them!)

There seems to be no way to disable this, and so I can't use browser-sync when debugging scroll events.

screen shot 2016-12-14 at 12 11 43

Here's the code in question: https://github.com/BrowserSync/browser-sync-client/blob/master/lib/ghostmode.scroll.js#L25

Suggestions:

Happy to contribute code fixes if you're happy with the approach. I don't know how to do the first one, though.

callumacrae commented 7 years ago

With browser-sync:

screen shot 2016-12-14 at 12 20 24

Without browser-sync:

screen shot 2016-12-14 at 12 18 16
shakyShane commented 7 years ago

@callumacrae Thanks for your investigations

When ghost mode is disabled, the event listener shouldn't be added

This was fixed in the last release

re: the second two point, I'm more than happy to get a PR for that. see https://github.com/BrowserSync/browser-sync-client/blob/master/lib/ghostmode.scroll.js

callumacrae commented 7 years ago

I'm running browser-sync start --server --files "*" --no-ghost-mode and browser-sync is still showing up in the timeline - am I disabling it correctly?

EDIT: I was out of date. whoops.