docs: add performance advice to disable default menu creation (#35525)

This commit is contained in:
Benjamin Pasero 2022-09-12 15:29:42 -07:00 committed by GitHub
parent b3a744db8a
commit 6ec4c7e563
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -419,6 +419,18 @@ environment that needs to handle both Node.js and browser environments.
As of writing this article, the popular choices include [Webpack][webpack],
[Parcel][parcel], and [rollup.js][rollup].
### 8. Call `Menu.setApplicationMenu(null)` when you do not need a default menu
Electron will set a default menu on startup with some standard entries. But there are reasons your application might want to change that and it will benefit startup performance.
#### Why?
If you build your own menu or use a frameless window without native menu, you should tell Electron early enough to not setup the default menu.
#### How?
Call `Menu.setApplicationMenu(null)` before `app.on("ready")`. This will prevent Electron from setting a default menu. See also https://github.com/electron/electron/issues/35512 for a related discussion.
[security]: ./security.md
[chrome-devtools-tutorial]: https://developers.google.com/web/tools/chrome-devtools/evaluate-performance/
[worker-threads]: https://nodejs.org/api/worker_threads.html