This solution fails when you need to insert the script more than once in a page. Instead, browsers really should provide scripts a means to retrieve the script element that they belong to.
scripts=document.elements.getElementByTagName('script')
latest=scripts[scripts.length-1]This approach allows you to specify parameters as JSON. So data of arbitrary length can be passed without having to resort to some global variable.
It solves a problem I had where I needed to pass some template engine generated content into an otherwise static script.
Thanks for the tip :)