Page MenuHomePhabricator

Deprecation status of importScript, importStylesheet, importScriptURI, importStylesheetURI
Closed, ResolvedPublic

Description

Summary for Tech News readers

  • importScriptURI( url ) and importStylesheetURI( url ) functions are deprecated. They have been superseded by ResourceLoader. You should replace their usages with mw.loader.load( url ). The old functions will be removed in the future.
  • importScript( wikiPage ) and importStylesheet( wikiPage ) functions are not deprecated yet. They will be deprecated when a suitable ResourceLoader-based replacement is created. For new scripts, it is recommended to use the Gadgets system instead.

Original bug summary:

These two functions have been on the list of deprecated JavaScript functions for a long time:
https://www.mediawiki.org/wiki/ResourceLoader/Legacy_JavaScript#wikibits.js

If they are in fact deprecated, users should see a warning in the console so that they can start migrating their code to mw.loader.load before these functions are finally removed from MW core.

See also:

Event Timeline

He7d3r created this task.Apr 13 2015, 10:17 PM
He7d3r updated the task description. (Show Details)
He7d3r raised the priority of this task from to Needs Triage.
He7d3r assigned this task to Krinkle.
He7d3r added subscribers: He7d3r, matmarex, TheDJ.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 13 2015, 10:17 PM
He7d3r closed this task as Resolved.Apr 13 2015, 10:22 PM

Change 203293 merged by jenkins-bot:
wikibits: Mark importScript/importStylesheet utilities as deprecated

https://gerrit.wikimedia.org/r/203293

Change 203873 merged by jenkins-bot:
wikibits: Mark importScript/importStylesheet utilities as deprecated

https://gerrit.wikimedia.org/r/203873

He7d3r reassigned this task from Krinkle to Schnark.Apr 13 2015, 10:25 PM
He7d3r set Security to None.
He7d3r added a subscriber: Krinkle.
TheDJ added a comment.Apr 14 2015, 7:28 AM

Hmm, i'm not sure this is wise...

onei added a subscriber: onei.Apr 14 2015, 7:47 AM

Something Wikia introduced after upgrading to 1.19 (i.e. have RL support) was importArticles, see http://community.wikia.com/wiki/Help:Including_additional_JavaScript_and_CSS for usage. It allows you to lookup pages by name (much like the now deprecated importScript/importStylesheet) and has all the benefits of RL. I believe it's just a wrapper for importScriptURI (perhaps swap it for mw.loader.load?), but it works really well on Wikia.

Schnark reassigned this task from Schnark to Krinkle.Apr 14 2015, 8:35 AM
Schnark added a subscriber: Schnark.

As long as this includes deprecating importScript and importStylesheet (rather than only importScriptURI and importStylesheetURI), I don't feel like this should be assigned to me, sorry.

Oh... I just took the owner of that Gerrit patch for filling in the assigned field on this Phabricator task.

He7d3r updated the task description. (Show Details)Apr 14 2015, 9:57 AM

Something Wikia introduced after upgrading to 1.19 (i.e. have RL support) was importArticles, see http://community.wikia.com/wiki/Help:Including_additional_JavaScript_and_CSS for usage. It allows you to lookup pages by name (much like the now deprecated importScript/importStylesheet) and has all the benefits of RL. I believe it's just a wrapper for importScriptURI (perhaps swap it for mw.loader.load?), but it works really well on Wikia.

That importArticles function is not a standalone shortcut for handling page names and interwiki codes. It is a handler for a larger custom framework they installed on their servers as extension to ResourceLoader.

https://github.com/Wikia/app/blob/ed0d816d/resources/wikia/wikia.wikibits.js#L20-L60
https://github.com/Wikia/app/blob/a86ae349/extensions/wikia/ArticlesAsResources/ArticlesAsResources.class.php

It doesn't handle registration or de-duplication. Nor any other features of ResourceLoader such as localisation. It serves mostly to combine and minify http requests. Performance isn't driving this issue however. Anything sufficiently widely used should become a Gadget, which supports ResourceLoader already. What's left is the shortcut syntax. Without a server component, we'd have to send all interwiki codes to the client (doesn't seem like a good idea).

We could use the hostname though. Perhaps something like this:

importFromWiki('commons.wikimedia.org', 'MediaWiki:Rtl.js');

Which would request https://commons.wikimedia.org/w/index.php?title=MediaWiki:Rtl.js&action=raw&ctype=text/javascript.

TheDJ added a comment.EditedApr 14 2015, 11:44 AM

I still assert that we have no good reason to deprecate these two functions, unless we have a plan or a methodology forward that depends on it. It's pointless to bother someone with deprecation warnings that tell him to rewrite something in a way that is functionally the same as what we had, but more wordy, with more chances of making mistakes.

And I'm sure that Commons will just happily 'undeprecate' the function on its own, continuing to use it in as is, or in a new form, further complicating the landscape. On top of that the issue that we want them to ultimately use 'something else' ANYWAY, so we can ask them to do another rewrite exercise.

This will result in a lot of 'I have better things to do'-style complaints. I don't see the problem in keeping these functions around until we are at a time where they can be replaced with something that offers tru benefits to the user.

XXN added a subscriber: XXN.Apr 20 2015, 3:36 PM

I'm with TheDJ. We still don't have a drop-in replacement... Wasn't this supposed to be superceded with GlobalGadgets/ResourceLoader 3.0 (or whatever version)? Until that is here, we should maintain these as (legacy) wrappers for mw.loader.load.

Rical added a subscriber: Rical.Apr 20 2015, 11:29 PM

Change 206078 had a related patch set uploaded (by Bartosz Dziewoński):
wikibits: Un-deprecate importScript and importStylesheet

https://gerrit.wikimedia.org/r/206078

matmarex reopened this task as Open.Apr 23 2015, 6:55 AM
matmarex added a project: MW-1.25-release.
matmarex renamed this task from Mark importScript and importStylesheet as deprecated to Mark importScript and importStylesheet as deprecated?.

Change 206078 merged by jenkins-bot:
wikibits: Un-deprecate importScript and importStylesheet

https://gerrit.wikimedia.org/r/206078

Change 206138 had a related patch set uploaded (by Bartosz Dziewoński):
wikibits: Un-deprecate importScript and importStylesheet

https://gerrit.wikimedia.org/r/206138

Change 206138 merged by jenkins-bot:
wikibits: Un-deprecate importScript and importStylesheet

https://gerrit.wikimedia.org/r/206138

matmarex updated the task description. (Show Details)Apr 23 2015, 4:35 PM
matmarex renamed this task from Mark importScript and importStylesheet as deprecated? to Deprecation status of importScript, importStylesheet, importScriptURI, importStylesheetURI.
matmarex updated the task description. (Show Details)
matmarex closed this task as Resolved.
matmarex removed a project: Patch-For-Review.
matmarex updated the task description. (Show Details)Apr 23 2015, 4:39 PM
SamB added a subscriber: SamB.Apr 28 2015, 9:13 PM
SamB added a comment.Apr 28 2015, 9:22 PM

So, um, I'm seeing these deprecation warnings (for importScript) on Wikidata ... that doesn't seem very resolved.

GOIII added a subscriber: GOIII.EditedApr 29 2015, 3:48 AM

Use of "importScript" is deprecated. Use mw.loader instead.

I'm seeing the same console message warning for importScript on en.wikipedia too -- mostly when entering an edit session.

It is still being used in their common.js file fwiw...

It hasn't been deployed yet. We could ping a dev to ask for a lightning deploy.

GOIII added a comment.EditedApr 29 2015, 7:56 AM

That will teach me to simply gloss over everything. Upon closer inspection - I see the WP roll-out hasn't happened yet though the status here is Closed.

that doesn't seem very resolved.

@SamB: See "Resolved".

Ltrlg added a subscriber: Ltrlg.May 1 2015, 5:59 PM
Restricted Application added a subscriber: StudiesWorld. · View Herald TranscriptDec 14 2015, 9:33 AM
Rical removed a subscriber: Rical.Jul 21 2017, 9:52 AM