Change demo around so script gets executed at the right time

Wrapped the code in a function, then called it after the SVG is
added to the DOM.