Last modified: 2012-06-20 04:55:23 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T34169, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 32169 - Action to join scripts and styles in one file
Action to join scripts and styles in one file
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
unspecified
All All
: Unprioritized enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on: gadgets-2.0
Blocks:
  Show dependency treegraph
 
Reported: 2011-11-03 07:41 UTC by Nux
Modified: 2012-06-20 04:55 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Nux 2011-11-03 07:41:06 UTC
Resource loader should allow to join main script with it's extensions to avoid race conditions when loading scripts in parallel (Firefox above 5/Chrome when scripts load in body). Would also be nice to optionally minimize them.

Something like that would work:
http://pl.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&titles[]=User:Nux/wp_sk.js&titles[]=User:Malarz_pl/wp_sk.js&titles[]=User:ToSter/wpsk_user.js

Order needs to be preserved.

BTW race condition occurs because of bug 27488.
Comment 1 Roan Kattouw 2011-11-03 10:17:14 UTC
When such scripts are made into modules through the new Gadgets extension, this'll automatically happen.

RL doesn't need hacks or workarounds for loading wiki pages, the wiki pages need to become modules. We've already solved these problems for modules, no need to solve them again for wiki pages.
Comment 2 Brion Vibber 2011-11-04 00:15:32 UTC
Provisionally adding dep on the RL2 tracking bug -- Roan is that appropriate or should this be closed out / merged with something?
Comment 3 Nux 2011-11-04 19:13:36 UTC
Not all scripts are gadgets. Also note that some scripts have extensions which is the case. Not all users of scripts use all extensions. It's not possible to create gadgets with all possible combinations.
Comment 4 Roan Kattouw 2011-11-08 11:21:24 UTC
(In reply to comment #3)
> Not all scripts are gadgets. Also note that some scripts have extensions which
> is the case. Not all users of scripts use all extensions. It's not possible to
> create gadgets with all possible combinations.
Ideally, extensions are separate modules.

Also, ideally, it should be possible to make modules out of user scripts without having them be gadgets. That's probably something we should be working on next. CC Krinkle for thoughts.
Comment 5 Nux 2011-11-10 07:23:02 UTC
Do note, that some script (and especially script extension creators) are admins so they create scripts in their own namespace (user namespace).

Anyway... Would you accept a patch for a quick fix like "titles[]" param mentioned above? This is a now-problem so I would like to have a solution in a foreseeable feature.
Comment 6 Beau 2011-11-10 07:55:20 UTC
That makes sense for a remote gadgets too. Instead of four mw.loader.load invocations there can be one (or two - depending on how styles are going to be supported), when loading gadgets from another wiki (for example: [[pl:s:MediaWiki:Gadget-searchbox.js]]).

Nux, as a workaround for now, you can turn the main script into a ResourceLoader compatibile gadget (or just a small part of it, which provides a thin interface for extensions) and then use in extensions the following code:

mw.loader.using( "ext.gadget.awesome", function() {
	// Register extension here
} );

This will automagically load the main script and after the script is loaded, the callback will be executed.
Comment 7 Roan Kattouw 2011-11-11 12:14:40 UTC
(In reply to comment #6)
> That makes sense for a remote gadgets too. Instead of four mw.loader.load
> invocations there can be one (or two - depending on how styles are going to be
> supported), when loading gadgets from another wiki (for example:
> [[pl:s:MediaWiki:Gadget-searchbox.js]]).
> 
Loading Gadgets from a remote wiki is a solved problem in the RL2 branch. mw.loader.load( 'gadget.foobar' ) (or mw.loader.using for that matter) will Just Work and will know which modules to load from which domain.

> Nux, as a workaround for now, you can turn the main script into a
> ResourceLoader compatibile gadget (or just a small part of it, which provides a
> thin interface for extensions) and then use in extensions the following code:
> 
> mw.loader.using( "ext.gadget.awesome", function() {
>     // Register extension here
> } );
> 
> This will automagically load the main script and after the script is loaded,
> the callback will be executed.
Yes, if you're an admin you can do this. If you're not an admin, you're screwed. That's a problem.
Comment 8 Roan Kattouw 2011-11-11 12:22:14 UTC
(In reply to comment #5)
> Do note, that some script (and especially script extension creators) are admins
> so they create scripts in their own namespace (user namespace).
> 
Yes, not everyone has the ability to create gadgets, so gadgets aren't the answer for everyone. This is a problem and I want to fix it at some point.

> Anyway... Would you accept a patch for a quick fix like "titles[]" param
> mentioned above? This is a now-problem so I would like to have a solution in a
> foreseeable feature.
My concern is that any quick fix for a now-problem will have to be supported indefinitely into the future.

That said, if the proposed patch is generic (i.e. allows concatenation of arbitrary wiki pages, not just JS pages), it wouldn't be that much of a burden to support from here on out, and it should be fine. Also, I would prefer &titles=Foo|Bar|Baz over &titles[]=Foo&titles[]=Bar&titles[]=Baz because the former is an established convention for api.php. Note that | is not a legal title character so it's safe to use as a separator.

So yes, patches are welcome :)
Comment 9 Nux 2011-12-14 17:20:49 UTC
Sorry, for the delays - was busy on other ends...

Anyway this seems to be harder then I thought it would be. What I was not aware is that all action classes assume an action occurs for one and only one page. Changing that behavior would probably break everything which is not what I'm willing to do ;-).

Anyway. You mentioned that you'd like it to join arbitrary pages not just JS pages so I'm assuming you don't want it in Resource loader. So do you think this should be an api module, special page (in an extension?) or did you had something else in mind?
Comment 10 Krinkle 2012-06-20 04:55:23 UTC
Marking this as INVALID.

RawAction is intended for loading the raw code of a WikiPage. Optionally the response can be given a custom Content-Type (e.g. for raw css or javascript loading). This type of loading is discouraged.

Another old feature is the ability for users to store and execute some javascript code from a fixed subpage name of their User page (User:Name/common.js and User:Name/<skin>.js).

The loading of other sub pages is not a feature, but an undocumented hack (still to date, not documented in the software). Whether documented or not, that ability is pure javascript (adding a <script> tag to another action=raw url) and not related to MediaWiki in any way. As such "user scripts" (other than /common.js and /<skin>.js) technically don't exist and therefore can not be improved because they are not recognized by the software. The only way to improve their handling is by creating a feature that recognizes these pages and deals with them. And... that's exactly what Gadgets and ResourceLoader does.

Note:

* Last year the basics of ResourceLoader have been brought to site scripts and to Gadgets. Gadgets can now make use of ResourceLoader optimization.

* Later this year (if all goes well), all of ResourceLoader and more will be brought to Gadgets, this will be released as Gadgets 2.0

* The next step is to extend Gadgets to have a user space (effectively introducing the concept of "user scripts" as an actual feature for the first time, because the currently used method is not a MediaWiki feature but pure javascript). This is currently just an idea, but if all goes well this will be started in 2013 as Gadgets 3.0. - bug 34958.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links