add fallback if document.currentScript is not available (e.g. with Webkitties)

Fixes #693
Please make this one or more separate documented functions.