From 6ec4c7e563c4bf59abb684e593bc6c0e0ee921c6 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 12 Sep 2022 15:29:42 -0700 Subject: [PATCH] docs: add performance advice to disable default menu creation (#35525) --- docs/tutorial/performance.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/tutorial/performance.md b/docs/tutorial/performance.md index f1648769ef4f1..d06a8220cff02 100644 --- a/docs/tutorial/performance.md +++ b/docs/tutorial/performance.md @@ -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