fallback to document.head if there is not any script tags in the dom

I did run in to a bug when the `target` was `undefined`.