Split out code just for the demo into demo.js