Emacs: Byte Compile Elisp Files

By Xah Lee. Date: . Last updated: .

What is Byte Compiled File

Emacs lisp files can be byte compiled.

emacs byte compiled file 2023-08-23 4kfT
emacs byte compiled file 2023-08-23 4kfT

Advantage of Byte Compiled Elisp File

As of today 2025-09-19, for init files and light-weight packages, byte compile don't make any noticeable speed difference.

emacs byte compile 2020-10-14 pCcgM
warnins and tips from byte compile elisp 2020-10-14

Disadvantage of Byte Compiled Elisp File

Byte compile creates a extra source of the code. If you edit elisp code and forget to byte compile it, it create a sync problem. Emacs usually check file date when loading a file, and if byte compiled file is older, emacs warns you.

Byte compile may not be compatible across different version of emacs or operating system. Technically it is, but sometimes not. When you are using a incompatible byte compiled file, it creates strange bugs.

How to Byte Compile Emacs Lisp File

There are several ways to byte compile elisp files. The simplest and most useful are:

Alt+x byte-compile-file
Compile a single file. It'll ask for a file name.
Alt+x dired-do-byte-compileB
Compile all marked files in dired.
Alt+x byte-recompile-directory
Batch compile all elisp files in current dir and subdirectory.

Loading Byte Compiled File

Recompile When Upgrade

you should recompile your personal elisp files when:

because, often emacs has some incompatible elisp changes, and big packages may fail without recompile.

Reference

2011-07-15 thanks to Adolfo Benedetti https://x.com/adben .

Emacs, Byte Compile