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