I am building a simple charting tool. When a user chooses a data source and a chart type, both the data and the script for the specific chart (.js) are loaded and then the code
Check Deferred it has modular build, and you can decide just to take core and that shouldn't be larger than 1kb.
Browser install instructions explains how to create such bundle in few easy steps