Add MediaWiki:Common.js file, similar to MediaWiki:Common.css
Closed, ResolvedPublic

Description

Author: webboy

Description:
Is it possible to make a [[MediaWiki:Common.js]] just like [[MediaWiki:Common.css]]?


Version: unspecified
Severity: enhancement

Details

Reference
bz4178
bzimport added a subscriber: Unknown Object (MLST).
bzimport set Reference to bz4178.
bzimport created this task.Dec 5 2005, 7:29 AM

robchur wrote:

Creating it would be possible. Do you mean, "would it have an effect?" I don't
believe so; not in the current incarnation.

webboy wrote:

Yes, I have made one (on nl.wikipedia.org) but it doesn't work. :-(

It would be nice when it works.

robchur wrote:

Changing to a feature request...

gangleri wrote:

Hallo!

[[en:MediaWiki:Common.css]] does not list inside [[en:Special:Allmessages]].
Should it?

regards reinhardt [[user:gangleri]]

ui2t5v002 wrote:

This could be fixed simply by adding a few lines to wikibits.js:

document.write('<scr' + 'ipt type="text/javascript"
src="http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js'

+ '&action=raw&ctype=text/javascript&dontcountme=s"></scr'
+ 'ipt>');

dto wrote:

You could also easily add this functionality in an extension:
http://en.wikipedia.org/wiki/User:Dto/CommonJSext

dto wrote:

(In reply to comment #6)

You could also easily add this functionality in an extension:
http://en.wikipedia.org/wiki/User:Dto/CommonJSext

Oops. Not quite. As far as I can tell, the BeforePageDisplay hook is only called
by SkinTemplate, and the standard/classic skin doesn't extend that.

dto wrote:

OK. Rewrote http://en.wikipedia.org/wiki/User:Dto/CommonJSext so that it works
independent of the current skin.

ingoolemo wrote:

Dan, I take it that said extension would have to be added to MediaWiki, and
couldn't be done client-side?

dto wrote:

(In reply to comment #9)

Dan, I take it that said extension would have to be added to MediaWiki, and
couldn't be done client-side?

Yeah, and so does everything else, I believe. If something is going to affect
every Wikipedia user, something in MediaWiki has to change, as far as I can tell.

dto wrote:

*** Bug 7072 has been marked as a duplicate of this bug. ***

ayg wrote:

Okay, Brion is apparently concerned with the possibility of adding more
unnecessary server hits. Ideally I suppose all the JS should be merged via PHP
into a single <script>, so that only one server hit occurs, but in lieu of that,
why not just ditch Monobook.js in favor of Common.js (in a backwards-compatible
way)? Why does Monobook need a separate script file anyway? If someone
actually wants to do separate stuff for Monobook, we have handy variables for that.

Anyone object to this? I'd probably just add lines to both Monobook and
Skin.php to the effect of using Common.js if it exists, otherwise Monobook.js
(as a deprecated fallback).

ingoolemo wrote:

(In reply to comment #12)

why not just ditch Monobook.js in favor of Common.js (in a backwards-compatible
way)? Why does Monobook need a separate script file anyway? If someone
actually wants to do separate stuff for Monobook, we have handy variables for that.

If I interpret some of what Simetrical says correctly, then it is possible to
collect scripts from all skins into a single repository; however, some scripts
would only work in certain skins, through the use of "hand variables".

If I interpret his proposal correctly, then I wholeheartedly support it. I
believe that this will be a useful step in providing better accommodation for
those of us who don't use the monobook skin.

Also, if I interpret Simetrical's proposal correctly, it would supersede the
need for a solution to Bug 6377.

I don't see why it would add more server hits; AFAIK, currently Monobook.js is
output from "/w/index.php?title=-&action=raw&gen=js", together with a couple of
extra variables; you could simply output Common.js together with it. Unless I'm
misunderstanding something, it wouldn't add any new server hits.

ayg wrote:

D'oh. You're right, of course. No problem, then: added in r17737.

ingoolemo wrote:

Regarding comment #12: are the "handy variables" PHP variables or Javascript
variables? If the latter, then I interpret Simetrical's comment to mean that
there is a way to specify which skin a particular function in
[[MediaWiki:Common.js]] would be executed in.

If this reading is true, then the Common repository would supersede any other
skin-specific repository, and obviate the need for a solution to Bug 6377.

Did I read correctly? I have to admit that I'm not much of techie.

ayg wrote:

You read correctly. The variable "skin" is provided in JavaScript on every page
and should be available to any script writers, and yes, I noted in a couple of
places that Monobook.js is deprecated (although not until I get around to
removing all those tooltips from it ;) ).

brion added a comment.Jun 3 2008, 8:42 PM

Just a note for posterity -- I've removed those deprecation notices; MediaWiki:Monobook.js and fellows are perfectly suitable for genuinely skin-specific JS... and it is indeed served along with MediaWiki:Common.js in the same server request (but only to those actually using that skin).

While general code does belong in Common.js, there's nothing wrong with using the specific ones when it's suitable.

Add Comment