This package ensures that only referenced packages are loaded. 2 is referenced by this example and 1 is referenced by 2. 3 and 4 are loaded, but as they aren't used by the page right away, they aren't loaded at the start.

Source files:

Package 1
Package 2
Package 3
Package 4
Package 5 (should never be loaded)

Click this button to run a script that requires package 4: