Next: Eval During Compile, Previous: Docs and Compilation, Up: Byte Compilation [Contents][Index]
When you compile a file, you can optionally enable the dynamic function loading feature (also known as lazy loading). With dynamic function loading, loading the file doesn’t fully read the function definitions in the file. Instead, each function definition contains a place-holder which refers to the file. The first time each function is called, it reads the full definition from the file, to replace the place-holder.
The advantage of dynamic function loading is that loading the file becomes much faster. This is a good thing for a file which contains many separate commands, provided that using one of them does not imply you will soon (or ever) use the rest. A specialized mode which provides many keyboard commands often has that usage pattern: a user may invoke the mode, but use only a few of the commands it provides.
The dynamic loading feature has certain disadvantages:
If you compile a new version of the file, the best thing to do is immediately load the new compiled file. That will prevent any future problems.
The byte compiler uses the dynamic function loading feature if the
variable byte-compile-dynamic
is non-nil
at compilation
time. Do not set this variable globally, since dynamic loading is
desirable only for certain files. Instead, enable the feature for
specific source files with file-local variable bindings, like this:
-*-byte-compile-dynamic: t;-*-
If this is non-nil
, the byte compiler generates compiled files
that are set up for dynamic function loading.
Default: nil.
This immediately finishes loading the definition of function from its byte-compiled file, if it is not fully loaded already. The argument function may be a compiled-function object or a function name.
Next: Eval During Compile, Previous: Docs and Compilation, Up: Byte Compilation [Contents][Index]