Home

autoload

Autoload is a software technique in which code or data is loaded only when it is actually needed, rather than at program startup. This on-demand loading aims to reduce initial startup time and memory usage, especially in large systems with many optional components. Autoloading is often paired with lazy loading, but the two terms are not strictly synonymous; lazy loading describes delaying work in general, while autoload specifically defers loading of modules or symbols until they are referenced.

How autoloading works varies by system. A loader or symbol resolver maintains a registry that maps names

Common implementations include:

- Lisp and Emacs Lisp, where autoload declarations specify that a function is defined in a separate

- Perl, via the AutoLoader module, which defers loading of subroutines until invoked.

- Python, using importlib or lazy import patterns to delay heavy imports until attributes or functions are

- PHP, with spl_autoload_register to automatically load classes upon first instantiation.

- Java and other JVM languages, where class loaders bring in classes on demand.

Benefits include faster startup and reduced memory footprint, while drawbacks can be increased complexity, latency on

to
their
defining
modules.
When
a
referenced
function,
class,
or
resource
is
first
used,
the
loader
loads
the
corresponding
module,
rebinds
the
symbol
to
the
loaded
implementation,
and
proceeds
with
execution.
Some
environments
use
explicit
declarations
to
mark
autoloadable
items,
while
others
employ
runtime
hooks
or
import
systems
that
intercept
first
access.
file
and
should
be
loaded
on
first
call.
accessed.
first
use,
and
debugging
or
profiling
challenges.
See
also
lazy
evaluation,
on-demand
loading,
and
dynamic
linking.