Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brainstorm: opportunities to improve main thread #4925

Open
paulirish opened this issue Apr 4, 2018 · 5 comments
Open

Brainstorm: opportunities to improve main thread #4925

paulirish opened this issue Apr 4, 2018 · 5 comments

Comments

@paulirish
Copy link
Member

paulirish commented Apr 4, 2018

Right now we do have diagnostics which summarize some main thread activity (main thread breakdown and bootup time), but we don't have any targeted opportunities regarding interactivity.

It'd be nice to help the users figure out how to improve the health of their main thread.


Few general approaches:

  1. Do less work
    • Don't do the work at all (Find needless stuff and nuke it)
    • Do the same work faster. (Profile it and speed it up.)
    • Do the work off the main thread.
  2. Split up long tasks.
  3. Do the work in downtime
    • Defer work till later, after TTI
    • Do work earlier, so TTI doesn't get pushed out

Maybe we can develop some heuristics to create specific suggestions?

@wardpeet
Copy link
Collaborator

maybe it's an idea to push people to Webworkers? By checking if tasks touch the dom?

@Schepp
Copy link

Schepp commented Apr 18, 2018

  • A good strategy to reduce initial load is to replace any DOMContentLoaded based component setup with an IntersectionObserver driven one. Components way down the fold need no immediate setup.

  • Defering below the fold component initialization with requestIdleCallback is also nice, although I hate how you determine visibility of an element currently. I would love a promised based DOM API for that (ideas here).

  • Web Workers are nice but most of the initial work involves DOM, so no big wins here. What I identified as suited is template rendering and eventually DOM diffing, if the DOM being diffed on both sides is virtual.

  • Maybe also hint at the fact that scripts cached by a Service Worker skip the parsing phase, which in turn means less time taken until execution?

@ebidel
Copy link
Contributor

ebidel commented Apr 18, 2018

a good strategy to reduce initial load is to replace any DOMContentLoaded based component setup with an IntersectionObserver driven one. Components way down the fold need no immediate setup.

I don't think we can safely assume this. Non-visual components could be low in the tree, display: none, etc. but still play an active part in rendering the page. e.g. a <firebase-db> element which fetches data for the page to render.

@midzer
Copy link
Contributor

midzer commented Oct 10, 2018

Maybe we could check how much % of JS is actually run on audited page and give a hint that X % is parsed and compiled without effect. Splitting up large bundles could be a major benefit for non-SPA apps on low end devices.

https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-coverage should provide necessary information for this approach.

edit: Code splitting is good practice for SPA, too. For example webpack recommends https://webpack.js.org/guides/code-splitting/

@patrickhulce
Copy link
Collaborator

We think @paulirish would be a great candidate to tackle this new audit, tentatively called "all of Lighthouse" ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants