perf: 90ms improvement: Defer more code in renderer, load state earlier

By deferring more code in the renderer and loading state earlier, we
improve startup time by another 90ms!

Before: 507 unique requires (1270-1280ms)
After: 506 unique requires  (1180-1190ms)
This commit is contained in:
Feross Aboukhadijeh
2016-09-30 22:00:58 -07:00
parent 02f5dbb63f
commit 5ff2d893b9
4 changed files with 49 additions and 28 deletions

View File

@@ -45,18 +45,26 @@ function init (state, options) {
y: initialBounds.y
})
win.once('ready-to-show', function () {
win.loadURL(config.WINDOW_MAIN)
win.once('ready-to-show', () => {
if (!options.hidden) win.show()
})
win.loadURL(config.WINDOW_MAIN)
if (win.setSheetOffset) win.setSheetOffset(config.UI_HEADER_HEIGHT)
if (win.setSheetOffset) {
win.setSheetOffset(config.UI_HEADER_HEIGHT)
}
win.webContents.on('dom-ready', function () {
menu.onToggleFullScreen(main.win.isFullScreen())
})
win.webContents.on('will-navigate', (e, url) => {
// Prevent drag-and-drop from navigating the Electron window, which can happen
// before our drag-and-drop handlers have been initialized.
e.preventDefault()
})
win.on('blur', onWindowBlur)
win.on('focus', onWindowFocus)