[whatwg] <script> features

On Sat, 24 Mar 2012 04:41:38 -0000, Ian Hickson <ian at hixie.ch> wrote:

>> The whole point of this feature is to enable the js-code inside a loaded
>> script to use the .currentScript property in order to find the <script>
>> element in the DOM which loaded it.
>
> Ah, ok. What's the use case for that?

Embedding of 3rd party widgets asynchronously:

<script async src="3rd-party-widget.js"></script>

Then the script could find its node in the document and replace it with  
whatever it wants.


Another use case would be a (superficial) emulation of document.write()  
for scripts that have been embedded asynchronously.

-- 
regards, Kornel Lesi?ski

Received on Saturday, 24 March 2012 16:57:37 UTC