Skip to main content

Tree-shaking

If you use the ESM builds of the library, this library fully supports tree-shaking, only the controllers you directly import will be bundled with your application.

When you have code that just imports a single controller:

import { AutoSubmitFormController } from "stimulus-library";

As long as your bundler supports it, only that one controller will be bundled into your application code. You don't have to ship the entire Stimulus-Library just to get the benefit of a single controller.

Further Reading:

Google Developers - What is Tree Shaking?

Rollup Tree Shaking

Webpack Tree Shaking