Use inline script for demos.
add onError function to allow custom error handling, closes #1