A PoC implementation of unused code elimination in runtime
It's a proof-of-concept implementation of unused code elemenation, which means Incinerator checks if a part of code is actually used in runtime and removes it if unused. For the time being, only function blocks are checked.
npm install incinerator
Please run incinerator
with actual runtime environment, for example,
webpack --watch
.
incinerator src/
The following is a link to the demo of an example with Chart.js, where bundle size is reduced from ~400K to ~80K.
The demo movie will be uploaded shortly.
I recommend reading the code, as it's only about 150 line long.
- Tag every function with a unique ID
- Check if a function is called in runtime via WebSocket
- When finished, remove uncalled functions
- Remove unused variables or undefined symbols manually
Please also consider playing with an example.