A comment on the article pointed out that since javascript execution is blocking, you can do that for synchronous javascript:
scripts=document.elements.getElementByTagName('script')
latest=scripts[scripts.length-1]