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 renders the chart.
Currently I use the following sequence:
- Load the chart script
- Load the data
- Render the chart
To improve performance, I’d like to implement promises and load script and data in parallel. A library like jQuery is too big for my needs (the point of the question is not to argue on this), are there more lightweight solutions? Maybe a 1-2 kb library, or a tutorial? Again, this is a very basic implementation with just two actions in parallel.
[Update] I upvoted all the replies as they all look excellent. I’ll report back after I do some more testing.
I built something like this a while back that I called “when-then”. I wanted something that would say, “Load all of these things, then do something when they’re done”.
https://github.com/geuis/when-then
I was inspired by the promises idea, but wanted something a little simpler for simple tasks.