This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Add-ons / Standard Packages / Appendix: How Mathematica Packages Are Set Up  /

Autoloading Packages

Explicit loading of packages is useful if you are trying to minimize the amount of memory used by your Mathematica session or if you are in an early stage of package development. However, most users find that they use a particular set of packages often, and they want those packages to load automatically.

Initialization Packages

Initializing all packages in a directory.

If you frequently use many functions from different packages in the same standard package directory, you will find it convenient to load the initialization package from that directory. After you load the initialization package you can use any of the functions contained in packages included in the directory. You will not need to load each package separately.
For example, <<Graphics` loads the initialization package Graphics`Kernel`init` and makes all the functions provided in the Graphics packages available in your current session. Using one of these functions will cause the appropriate package to be loaded if it has not been loaded already. An initialization package really consists of nothing more than a sequence of DeclarePackage commands.

  • This loads the Graphics`Kernel`init` package. All the functions contained in Graphics packages are now available for use.
  • In[1]:= <<Graphics`

  • Since the Graphics`Graphics` package defining BarChart has not yet been loaded, using BarChart will cause the package to load.
  • In[2]:= BarChart[{1.2, 3.4, 2.2, 1.8}]

    Autoload Directory

    The main Mathematica distribution CD-ROM typically includes the standard add-on packages described in this book, placed in the AddOns/StandardPackages/ subdirectory of your main Mathematica directory. Mathematica application packages, such as Electrical Engineering, are usually installed in the AddOns/Applications/ subdirectory. The AddOns/Autoload/ subdirectory provides another way to autoload packages.

    Directories for Mathematica packages.

    If you would like Mathematica to automatically load the initialization file for a directory of packages whenever you start the kernel, then you should copy the initialization file into the appropriate place in the AddOns/Autoload/ directory. For example, you might copy AddOns/StandardPackages/Graphics/Kernel/init.m into AddOns/Autoload/Graphics/Kernel/init.m so that all graphics packages will load as needed. If you have the Electrical Engineering application, you might copy AddOns/Applications/EE/Kernel/init.m into AddOns/Autoload/EE/Kernel/init.m so that the Electrical Engineering application will load as needed. Effective use of the Autoload directory allows you to create a version of Mathematica tailored to your needs.