Purge unused directives from js bundle #3347
acalvino4
started this conversation in
3. Feature Ideas
Replies: 1 comment
-
|
I mean, the module you install is pre compiled as is, so I don't see this being a likely thing to do. The current way the package is built and deployed is woefully out of style with modern standards. It could really be something a vite plugin could do pretty well, as a virtual module that checks your html for directives and only adds the ones that you use (could also work for the data as well) but might need major changes to the current build process. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
One of the (several) things that made tailwind so popular is that is has a streamlined system for purging all unused styles and leaving you with the smallest bundle possible. I don't know exactly how this would work, or how much bandwidth it would save, but it seems like alpine could benefit from this (I know, it's not huge for a js framework, but when you have to throw in a few plugins, and in the hopefully near future, alpine's headless ui, I'm seeing roughly 100 kb uncompressed - not terrible, but not super impressive)
In javascript apps with an 'entry point', this purging is done through 'tree-shaking', but with a framework like alpinejs, that doesn't really work since it is usually used alongside a templating language where the build process has no introspection capability. I think an awesome feature would be some way of scanning template files to see what alpine directives are used, and only including the code for those in the final bundle.
It's possible this is more of an idea for a vite plugin, but it seems this is still the best place to ask how feasible and beneficial the idea even is.
Beta Was this translation helpful? Give feedback.
All reactions