1

Do .elc files take precedence over .el files when using load?

Say I have two files in my load path: foo.el and foo.elc. If I call (load "foo"), will the byte-compiled version (foo.elc) always be loaded instead of the uncompiled foo.el?

Ben
  • 587
  • 4
  • 11
  • Yes. See the Emacs manual, node [Lisp Libraries](http://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Libraries.html). (Ask Emacs.) – Drew Feb 24 '17 at 16:34
  • See also `load-prefer-newer`, which can customize this behavior. – glucas Feb 24 '17 at 18:23

2 Answers2

5

By default the .elc would be loaded rather than the .el, as noted in the other answers/comments.

A few things can affect this behavior, however:

  • Set load-prefer-newer to t if you want to load whichever file is newer. In that case the .el will be loaded if it has been modified more recently than the corresponding .elc file.

  • See the variable load-suffixes, which defines the suffixes that load will try, in order of preference.

glucas
  • 20,175
  • 1
  • 51
  • 83
0

Yes, .elc files take precedence over .el files, even if they both exist in your load path.

According to emacswiki.org:

When both a byte-compiled file (.elc) and a source file (.el) are found for the same library, preference is given to byte-compiled file.

Ben
  • 587
  • 4
  • 11
  • 2
    The wiki is generally (and in this case) a good source. But Emacs is typically a better source, when it covers the same information. – Drew Feb 24 '17 at 16:35