[Mediawiki-l] add new js.file

Jim Higson jh at 333.org
Fri Aug 31 09:12:06 UTC 2007


Jim Wilson wrote:

> If you want to be really slick about it, you could try adding the
> following to the article [[MediaWiki:Common.js]]
> 
> (function(){
> var s = document.createElement('script');
> s.src = "http://path/to/external/file.js";
> document.getElementsByTagName('head')[0].appendChild(s);
> })();
> 
> This will dynamically create the equivalent of this:
> 
> <script src="http://path/to/external/file.js"></script>
> 
> To your the document head.

IIRC, According to a comment in the scriptalicious code, Safari 2 won't work
with this, so you have to use the bad old document.write instead.

Haven't tested it myself.

-- 
Jim





More information about the MediaWiki-l mailing list