Speed up Emacs with Features, Requires, and Autoloads

One can considerably speed up one's emacs but transferring common functions from init.el to a directory with .el files and the byte-compiling those files.

One does not generally byte-compile init.el

A file with a group of related functions is called a feature.

Steps:

Create a dir in .emacs.d and add this to init.el near top

(setq load-path (cons "~/.emacs.d/dotemacs/" load-path))

Create a .el file in this directory with your related functions

Add

(provide 'name-file-without-extension) to the bottom of file

Add in init.el emacs:

(autoload name-function "name-of-feature")

The function will only be called when needed, speeding up emacs.

Byte compile the feature file(s) in dired with b

Feature files that contain code besides functions can be required instead of autoloaded.

When you use (require 'feature), Emacs will load the entire file that provides that feature, including all the code in that file, not just function definitions.

Though the code is not called on demand with this, one can byte compile the file and it will speed up emacs.

Examples