3.1 How and when use-package loads packages

The call to the use-package macro will load a package either immediately, or when the package is first used (via autoloading). In the simplest case, a use-package declaration loads a package when it is evaluated.1 If the declaration is in your init file, this happens automatically each time Emacs is started.

For example, the declaration below immediately loads the library foo, just like require would:

(use-package foo)

If the library ‘foo’ is not available in your load-path, the declaration logs a warning to the ‘*Messages*’ buffer.

Note that a “package” is different from an Emacs Lisp “library”. The above declaration tells use-package to load the library foo.el, which in the overwhelming majority of cases also resides in a package named foo. But the package foo might also contain a library named foo-extra.el. If that library is not loaded automatically, you will need a separate use-package declaration to make sure that it is loaded when needed. This manual will often use the terms “package” and “library” interchangeably, as this distinction does not usually matter, but you should keep it in mind for the cases when it does.

The details of how and when you should load a package might differ from one package to another. When in doubt, refer to the package documentation for details.


Footnotes

(1)

This happens both at run-time and at compile-time. See Byte-compiling your init file.