Hi!
I was wondering if wouldn't be better to have the snippets code in real .js pages (e.g. on MediaWiki: namespace, problably as gadgets) so that people could use
mw.loader.load( '//www.mediawiki.org/w/index.php?title=MediaWiki:SomeSnippet.js&action=raw&ctype=text/javascript' );
instead of copying the source from Mediawiki pages. The migration guide suggests we should avoid duplication of code.
In case it is necessary to display the source on documentation page, that could be achieved easily by using something like
{{#tag:syntaxhighlight |{{:MediaWiki:Gadget-HotCat.js}} |lang=javascript }}
which results in
mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' );
which is the content of MediaWiki:Gadget-HotCat.js.