Page MenuHomePhabricator

User custom JS <script> tag changes location in some MW skins
Closed, DeclinedPublic

Description

Author: haza.wiki

Description:
For some reason, certain skins cause the Javascript elements in the document head to appear in a different order, causing user scripts to break if they depend on a script which appears after their user JS is invoked.

Monobook, Chick, Modern, MySkin and Simple call the JS scripts in the correct order - ie. site JS and custom user script at the end of the document head, shown below.

		<script type="text/javascript" src="/skins-1.5/common/wikibits.js?182"><!-- wikibits js --></script>
		<!-- Head Scripts -->
		<script type="text/javascript" src="/skins-1.5/common/ajax.js?182"></script>
		<script type="text/javascript" src="/skins-1.5/common/ajaxwatch.js?182"></script>
		<script type="text/javascript" src="/skins-1.5/common/mwsuggest.js?182"></script>

<script type="text/javascript">/*<![CDATA[*/
var wgNotice='';var wgNoticeLocal='';
/*]]>*/</script> <script type="text/javascript" src="http://upload.wikimedia.org/centralnotice/wikimedia/en/centralnotice.js?182"></script>

		<script type="text/javascript" src="/w/index.php?title=-&amp;action=raw&amp;smaxage=0&amp;gen=js&amp;useskin=monobook"><!-- site js --></script>
		<script type="text/javascript" src="/w/index.php?title=User:Haza-w/monobook.js&amp;action=raw&amp;ctype=text/javascript"></script>

</head>

Classic, Cologne Blue and Nostalgia call the site JS and custom user script *before* some of the other JS libraries, which causes scripts dependent on those libraries to break.

		<script type="text/javascript" src="/skins-1.5/common/wikibits.js?182"></script>
		<script type="text/javascript" src="/w/index.php?title=-&amp;action=raw&amp;smaxage=0&amp;gen=js&amp;useskin=standard"><!-- site js --></script>
		<script type="text/javascript" src="/w/index.php?title=User:Haza-w/standard.js&amp;action=raw&amp;ctype=text/javascript"></script>				<script type="text/javascript" src="/skins-1.5/common/ajax.js?182"></script>

		<script type="text/javascript" src="/skins-1.5/common/ajaxwatch.js?182"></script>
		<script type="text/javascript" src="/skins-1.5/common/mwsuggest.js?182"></script>

<script type="text/javascript">/*<![CDATA[*/
var wgNotice='';var wgNoticeLocal='';
/*]]>*/</script> <script type="text/javascript" src="http://upload.wikimedia.org/centralnotice/wikimedia/en/centralnotice.js?182"></script>

		</head>

The cause of the bug might not rest with the skins themselves, but it would be useful if this were diagnosed and rectified.


Version: unspecified
Severity: normal
URL: http://meta.wikimedia.org/wiki/Main_Page

Details

Reference
bz16258

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 10:23 PM
bzimport set Reference to bz16258.
bzimport added a subscriber: Unknown Object (MLST).

herd wrote:

More fully documented (by me, annoying amount of work) at http://en.wikipedia.org/wiki/Wikipedia:Catalogue_of_CSS_classes#Stylesheets_and_JavaScript (except they changed it with the central notice, which I am ignoring as it is transient for the next few weeks and will totally change next year, like every year).

Can you give an example of such a script that breaks? Basically my rule of thumb is: if you rely on any javascript that isn't in the global definition (wgPagename etc) or wikibits.js, use it inside an addOnloadHook().

haza.wiki wrote:

I don't know of any that break for this reason, to be honest - I encountered the issue when creating an AJAX-dependent extension to http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Six_tabs and testing it for cross-skin compatibility.

If it's a non-issue, then there's no need for a fix. I just thought that continuity would be better than disparity in this context, since it makes logical sense for gadgets and user scripts to be executed after the global and skin scripts.

That's an excellent resource, by the way... definitely going into the bookmarks :)