News for hackers. Stuff that matters.
Re:Show HN: Auto-generate vanilla JavaScript alternatives fo... by fabiospampinato on Monday September 06, 2021 @09:42AM (#28433543)
jQuery is not tree-shakeable because it uses a chainable API. Like you don't import `toggleClass`, you access the `toggleClass` property of a jQuery instance, so it can't be tree-shaken off automatically.

Even if somebody made a bundler plugin for doing the heavy work jQuery can only be partially compiled with whole modules excluded, you can't exclude individual methods (e.g. you can't just remove `toggleClass`, you have to remove also `addClass`, `removeClass` etc.).

FYI I maintain a jQuery alternative that supports being partially compiled with individual modules turned off, but it requires manually listing them: https://github.com/fabiospampinato/cash

There are no comments on this comment yet.