Emacs HEAD (27+) introduces early-init.el, which is run before init.el, before package.el and the first graphical frame is initialized.
;;; early-init.el -*- lexical-binding: t; -*-
The GC can easily double startup time, so we suppress it at startup by turning up gc-cons-threshold and gc-cons-percentage temporarily. However, it is important to reset it eventually, to prevent GC freeze during long-term interactive use, and gc-cons-threshold that is too small cause stuttering.
(defvar init-gc-cons-threshold gc-cons-threshold)
(defvar init-gc-cons-percentage gc-cons-percentage)
(setq gc-cons-threshold most-positive-fixnum
gc-cons-percentage 0.6)
(add-hook 'emacs-startup-hook
(lambda ()
(setq init-gc-cons-threshold
init-gc-cons-percentage)))
Packages are made available before reading the init file (but after reading the early init file). we must prevent Emacs from doing it early!
(setq package-enable-at-startup nil)
(advice-add #'package--ensure-init-file :override #'ignore)
(push '(menu-bar-lines . 0) default-frame-alist)
(push '(tool-bar-lines . 0) default-frame-alist)
(push '(vertical-scroll-bars) default-frame-alist)
Whether frames should be resized implicitly. If this option is nil, setting font, menu bar, tool bar, tab bar, internal borders, fringes or scroll bars of a specific frame may resize the frame in order to preserve the number of columns or lines it displays. If this option is t, no such resizing is done.
(setq frame-inhibit-implied-resize t)
its settings would be redundant with the other settingsin this file and can conflict with later config (particularly where the cursor color is concerned).
(advice-add #'x-apply-session-resources :override #'ignore)
(load
(expand-file-name "init.el" user-emacs-directory) nil 'nomessage 'nosuffix)