Let's assume that i have a single javascript file that I have handed out to a lot of my clients, similar to GA's *ga.js, and this file is getting loaded high enough number of times that I have to host it on a CDN.
The problem I have with this setup is that it makes it really hard to 'stage' a new version of javascript. Ideally, when I have a new version of the JS, I would like to split the incoming traffic to the CDN, and send 1% of the entire traffic to the new JS (randomly chosen), or possibly send the new JS only to specific URLs.
I have come across this issue multiple times and have not come up with a good solution. One possible solution is working with the CDN, though it is a long process. Alternative solution is having the customers always load a bootstrapper javascript, which knows where the actual JS or the staged JS lives and splits traffic accordingly.
I am curious if there is alternative solutions people have come up with. This is common enough problem for any company that distributes their JS like, Google, Twitter, Facebook, Linkedin, etc.