[whatwg] (deferred) script tags with document.write built in

Ian Hickson ian at hixie.ch
Thu Aug 12 01:19:37 PDT 2010


On Sat, 24 Jul 2010, Brett Zamir wrote:
>
> Might there be a way that <script/> tags could add an attribute which 
> combined the meaning of both "defer" and "document.write", whereby the 
> last statement was evaluated to a string, but ideally treated, as far as 
> the DOM, with the string being parsed and replacing the containing 
> script node.
> 
> For example:
> 
> <script  write>
>     '<span  onmouseover="alert(\''+(new Date())+'\')">I\'ve got the
> date</span>'
> </script>
> 
> If E4X were supported (since we otherwise lamentably have no PHP-style 
> HEREDOC syntax in JavaScript to minimize the few warts above), allowing 
> this to be used could be especially convenient:
> 
> <script  write>
>     <span  onmouseover="alert(new Date())">I've got the date</span>
> </script>
> 
> (Maybe even a new <write/> tag could be made to do this exclusively and 
> more succinctly.)
> 
> I chose "defer" as the default behavior so as to be XHTML-friendly, to 
> allow convenient reference by default to other DOM elements without the 
> need for adding a listener, and the more appealing default behavior of 
> not blocking other content from appearing.
> 
> Since it doesn't seem that XQuery support will be making it into 
> browsers anytime soon, it would be nice to be able to emulate its clean 
> template-friendly declarative style, dropping the need to find and 
> append to elements, etc..

I don't really see what this proposal would solve. Can you elaborate on 
what this would allow that can't be done today?

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list