Hi all!
What is the best way to control load order of JS (or modules modules in
general)? We (WMDE) are developing WikiPraise, a gadget that can show directly
show who contributed which part of a given article revision, as shown to the user.
WikiPraise works by taking the wikitext annotated with authorship info (a "blame
map", currently provided by the CollaborativeTrust project), render it to html,
then note the offsets of the marker in the generated html (ignoring markup and
whitespace), and store them. When showing a page, the gadget fetches this
authorship info and applies it to the html DOM of the content of the page.
Thomas Schmidt (User:NetAction), who is developing WikiPraise for us, ran into a
problem with other user scripts manipulating the DOM. Since we modify the DOM
based on html offsets, any prior modification of the DOM will break the output.
Thus, WikiPraise must run before any other JS that may modify the DOM.
So, what would be the best way to achieve that? Perhaps we could write an
extension that does nothing but causing the WikiPraise JS code to be loaded
early enough?
We could of course do the entire Wikitext-to-HTML transform on every page view,
instead of trying to annotate the DOM based on a pre-generated, offset based
blame map. But that would a) also have to happen before any other user script
runs and b) would be prohibitively slow (try the WikiTrust plugin for firefox to
see what i mean).
Note that we plan to have this enabled per default even for anons. The idea is
to provide an easy way for fully compliant re-use citing all authors of some
section of an article, and also allowing readers to get a better idea who wrote
what, and what can be trusted.
Anyway: rendering the content based on the annotated wikitext on every page view
would likely melt the servers, so it's not an option. We need to be able to
apply some sort of pre-generated blame map to the DOM.
Or, of course, we could hook into the parser and do all this inside mediawiki.
We we'd need to call out to fetch or generate the blame map when parsing. If we
had a high performance blame implementation that could be tightly integrated
with mediawiki, this would work. I would prefer that, and we might work towards
that, but it would be nice to have a low-impact implementation first. And the
current approach works pretty well, except for other user scripts interfering.
To try WikiPraise, put this into your common.js:
$.holdReady(true);
mediaWiki.loader.load("https://toolserver.org/~netaction/wikitrust.js&….js");
Note that this will disable all gadgets and custom scripts: $.holdReady(true) is
a hack to prevent other user scripts from running. That sucks of course.
Any ideas?
-- daniel