Is it safe to assume that the last script
element* in the document when the script runs** is the currently running script?
For example, I want to create
It's not an absolute guarantee no. Check out this JSFiddle: http://jsfiddle.net/jAsek/
Test case
At the start
After the first script
At the end
Here the alert reports the id of the injected script "early", not the id of currently running script "second".
There's no practical difference between internal and external scripts.