With the combination of web-js and web-twig you can easily manage your js components and control your loaded JS code.
To install the demo you should clone this project:
https://github.com/sulu/web-js-twig-demo.git
cd web-js-twig-demo
Then install the PHP dependencies using composer.
composer install
Then go into the assets/website folder and install the JS dependencies using npm.
cd assets/website
npm install
The easiest way to start the demo is by using the PHP internal webserver.
php -S 127.0.0.1:8000 -t public
When you now visit http://127.0.0.1:8000 the demo should appear.