Skip to content

A PoC implementation of unused code elimination in runtime

License

Notifications You must be signed in to change notification settings

hatashiro/incinerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Incinerator

Incinerator of Reg

A PoC implementation of unused code elimination in runtime

What's this?

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.

Install

npm install incinerator

How to use

Please run incinerator with actual runtime environment, for example, webpack --watch.

incinerator src/

Demo

The following is a link to the demo of an example with Chart.js, where bundle size is reduced from ~400K to ~80K.

Youtube: Incinerator Demo

Before incineration

before

After incineration

after

How Incinerator works

I recommend reading the code, as it's only ~200 lines long.

  1. Tag every function with a unique ID
  2. Check if a function is called in runtime via WebSocket
  3. When finished, empty uncalled functions
  4. Remove unused top-level variables to remove unused dependencies

Please also consider playing with an example.

License

ISC

About

A PoC implementation of unused code elimination in runtime

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published