Faster Emacs with early init
Two init files #
I have known about early-init.el for a long time now, but never saw the appeal, until I understood two things:
- Things like the scroll bar or the tool bar first get activated, and then
init.eldisables them. - Garbage collection can be affected at different steps of the initialisation process.
I learned from this source (archive) about such things, and the garbage collection settings seemed cleaner than what I saw elsewhere.
Improvement speed #
I stole the following function:
(defun efs/display-startup-time ()
(message "Emacs loaded in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done))
(add-hook 'emacs-startup-hook #'efs/display-startup-time)
From this (archive) SystemCrafters post. It shows that my old init.el started up in ~1.1s, while the new one starts in ~0.5s. The difference is actually noticeable, especially the early flickering caused by all the GUI elements being turned off.
Emacs usually stays open for long periods of time, but this change is still very much welcome.