TL:DR; Double-check your wiki's site scripts and your personal scripts to ensure "document.write" is no longer used.
Hey all,
We have strongly discouraged for many years the use of synchronous "document.write()" to inject additional HTML into the output stream. Across MediaWiki core, extensions, and gadgets this hasn't worked since 2012. With two legacy exceptions: the 'site' and 'user' modules. We always found a way to continue support for those. But this is now going to be removed.
In upcoming ResourceLoader upgrades and performance improvements, we will cease support for synchronous document-write, in the site and user modules. Use of document-write requires MediaWiki to instruct the browser to pause its rendering before the browser may proceed to parse and display a page to users.
Even though most scripts don't use this feature, the mere fact that we support it is causing a measurable impact on page load performance.
Starting in 1.26wmf17 (released to wikis this week), ResourceLoader will be fully asynchronous. This change is already live on the Beta Cluster. [1] This means it is no longer possible for the site and user scripts to, with document-write, pause the browser execution and insert additional HTML in the initial output stream.
Removing an API does not necessarily mean removing a capability. If you encounter any issues or can't find a simple upgrade path for an existing script, please reach out on the mailing list. Below is summary of a few typical use cases:
1. Loading scripts.
Instead of `document.write("<script src=url></script>");` use `mw.loader.load(url);` instead.
2. Loading stylesheets.
Instead of `document.write("<link rel=stylesheet href=url/>");` use `mw.loader.load(url, "text/css");` instead.
3. Creating elements.
Instead of `document.write("<div>....</div>");`, use:
var nodes = $.parseHTML("<div>..</div>"); $('body').append(nodes);
Or something like:
$("<div>").attr({ "id": "foo" }).appendTo("body");
Please take some time to look through your wiki's site scripts (MediaWiki:Common.js, MediaWiki:Vector.js, etc.) and make sure document-write is no longer used. You can also use the search engine. For example:
https://nl.wikipedia.org/w/index.php?search=document.write&ns8=1 https://commons.wikimedia.org/w/index.php?search=document.write&ns8=1
Search results from mwgrep on all public wikis: https://phabricator.wikimedia.org/P1832
Check out the migration page for other deprecations and common issues you may encounter: https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)
== Further reading ==
The ResourceLoader improvements that led to this change are tracked under https://phabricator.wikimedia.org/T107399.
Refer to the following workboards for other tasks in this area: https://phabricator.wikimedia.org/tag/mediawiki-resourceloader/board/?order=... https://phabricator.wikimedia.org/tag/performance-team/board/?order=priority
Now that the site and user modules are primary citizens in the ResourceLoader landscape, their states can be tracked with mw.loader. This solves long-outstanding issues such as https://phabricator.wikimedia.org/T106736 which sometimes caused malfunctions in Common.js to affect user gadgets, VisualEditor, and other site tools.
— Krinkle
I think this announcement is missing one important tidbit:
If you have `document.write(…)` anywhere in your user JavaScript, **you will get a blank page** on all pages of your wiki *, including the user JavaScript page you'd have to edit to fix it, until you disable JavaScript in your browser or ask an administrator to fix it for you.
If you have `document.write(…)` anywhere in the site JavaScript, **all users** will **get a blank page** on all pages of the wiki *, including anonymous readers, including all administrators who could fix it, until one of them disables JavaScript in their browser, and finds and fixes the broken script.
* Except for Special:Preferences and password-related pages, where user and site JavaScript is disabled for security reasons.
On Thu, 06 Aug 2015 01:24:03 +0200, Krinkle krinklemail@gmail.com wrote:
TL:DR; Double-check your wiki's site scripts and your personal scripts to ensure "document.write" is no longer used.
Hey all,
We have strongly discouraged for many years the use of synchronous "document.write()" to inject additional HTML into the output stream. Across MediaWiki core, extensions, and gadgets this hasn't worked since 2012. With two legacy exceptions: the 'site' and 'user' modules. We always found a way to continue support for those. But this is now going to be removed.
In upcoming ResourceLoader upgrades and performance improvements, we will cease support for synchronous document-write, in the site and user modules. Use of document-write requires MediaWiki to instruct the browser to pause its rendering before the browser may proceed to parse and display a page to users.
Even though most scripts don't use this feature, the mere fact that we support it is causing a measurable impact on page load performance.
Starting in 1.26wmf17 (released to wikis this week), ResourceLoader will be fully asynchronous. This change is already live on the Beta Cluster. [1] This means it is no longer possible for the site and user scripts to, with document-write, pause the browser execution and insert additional HTML in the initial output stream.
Removing an API does not necessarily mean removing a capability. If you encounter any issues or can't find a simple upgrade path for an existing script, please reach out on the mailing list. Below is summary of a few typical use cases:
- Loading scripts.
Instead of `document.write("<script src=url></script>");` use `mw.loader.load(url);` instead.
- Loading stylesheets.
Instead of `document.write("<link rel=stylesheet href=url/>");` use `mw.loader.load(url, "text/css");` instead.
- Creating elements.
Instead of `document.write("<div>....</div>");`, use:
var nodes = $.parseHTML("<div>..</div>"); $('body').append(nodes);
Or something like:
$("<div>").attr({ "id": "foo" }).appendTo("body");
Please take some time to look through your wiki's site scripts (MediaWiki:Common.js, MediaWiki:Vector.js, etc.) and make sure document-write is no longer used. You can also use the search engine. For example:
https://nl.wikipedia.org/w/index.php?search=document.write&ns8=1 https://commons.wikimedia.org/w/index.php?search=document.write&ns8=1
Search results from mwgrep on all public wikis: https://phabricator.wikimedia.org/P1832
Check out the migration page for other deprecations and common issues you may encounter: https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)
== Further reading ==
The ResourceLoader improvements that led to this change are tracked under https://phabricator.wikimedia.org/T107399.
Refer to the following workboards for other tasks in this area: https://phabricator.wikimedia.org/tag/mediawiki-resourceloader/board/?order=... https://phabricator.wikimedia.org/tag/performance-team/board/?order=priority
Now that the site and user modules are primary citizens in the ResourceLoader landscape, their states can be tracked with mw.loader. This solves long-outstanding issues such as https://phabricator.wikimedia.org/T106736 which sometimes caused malfunctions in Common.js to affect user gadgets, VisualEditor, and other site tools.
— Krinkle
[1] http://en.wikipedia.beta.wmflabs.org/
Wikitech-ambassadors mailing list Wikitech-ambassadors@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-ambassadors
Already reported as https://phabricator.wikimedia.org/T108139
On Wed, Aug 5, 2015 at 5:10 PM, Bartosz Dziewoński matma.rex@gmail.com wrote:
I think this announcement is missing one important tidbit:
If you have `document.write(…)` anywhere in your user JavaScript, **you will get a blank page** on all pages of your wiki *, including the user JavaScript page you'd have to edit to fix it, until you disable JavaScript in your browser or ask an administrator to fix it for you.
If you have `document.write(…)` anywhere in the site JavaScript, **all users** will **get a blank page** on all pages of the wiki *, including anonymous readers, including all administrators who could fix it, until one of them disables JavaScript in their browser, and finds and fixes the broken script.
- Except for Special:Preferences and password-related pages, where user
and site JavaScript is disabled for security reasons.
On Thu, 06 Aug 2015 01:24:03 +0200, Krinkle krinklemail@gmail.com wrote:
TL:DR; Double-check your wiki's site scripts and your personal scripts
to ensure "document.write" is no longer used.
Hey all,
We have strongly discouraged for many years the use of synchronous "document.write()" to inject additional HTML into the output stream. Across MediaWiki core, extensions, and gadgets this hasn't worked since 2012. With two legacy exceptions: the 'site' and 'user' modules. We always found a way to continue support for those. But this is now going to be removed.
In upcoming ResourceLoader upgrades and performance improvements, we will cease support for synchronous document-write, in the site and user modules. Use of document-write requires MediaWiki to instruct the browser to pause its rendering before the browser may proceed to parse and display a page to users.
Even though most scripts don't use this feature, the mere fact that we support it is causing a measurable impact on page load performance.
Starting in 1.26wmf17 (released to wikis this week), ResourceLoader will be fully asynchronous. This change is already live on the Beta Cluster. [1] This means it is no longer possible for the site and user scripts to, with document-write, pause the browser execution and insert additional HTML in the initial output stream.
Removing an API does not necessarily mean removing a capability. If you encounter any issues or can't find a simple upgrade path for an existing script, please reach out on the mailing list. Below is summary of a few typical use cases:
- Loading scripts.
Instead of `document.write("<script src=url></script>");` use `mw.loader.load(url);` instead.
- Loading stylesheets.
Instead of `document.write("<link rel=stylesheet href=url/>");` use `mw.loader.load(url, "text/css");` instead.
- Creating elements.
Instead of `document.write("<div>....</div>");`, use:
var nodes = $.parseHTML("<div>..</div>"); $('body').append(nodes);
Or something like:
$("<div>").attr({ "id": "foo" }).appendTo("body");
Please take some time to look through your wiki's site scripts (MediaWiki:Common.js, MediaWiki:Vector.js, etc.) and make sure document-write is no longer used. You can also use the search engine. For example:
https://nl.wikipedia.org/w/index.php?search=document.write&ns8=1 https://commons.wikimedia.org/w/index.php?search=document.write&ns8=1
Search results from mwgrep on all public wikis: https://phabricator.wikimedia.org/P1832
Check out the migration page for other deprecations and common issues you may encounter: https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)
== Further reading ==
The ResourceLoader improvements that led to this change are tracked under https://phabricator.wikimedia.org/T107399.
Refer to the following workboards for other tasks in this area:
https://phabricator.wikimedia.org/tag/mediawiki-resourceloader/board/?order=...
https://phabricator.wikimedia.org/tag/performance-team/board/?order=priority
Now that the site and user modules are primary citizens in the ResourceLoader landscape, their states can be tracked with mw.loader. This solves long-outstanding issues such as https://phabricator.wikimedia.org/T106736 which sometimes caused malfunctions in Common.js to affect user gadgets, VisualEditor, and other site tools.
— Krinkle
[1] http://en.wikipedia.beta.wmflabs.org/
Wikitech-ambassadors mailing list Wikitech-ambassadors@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-ambassadors
-- Bartosz Dziewoński
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Fixed, and deployed.
Thanks for reporting and sorry for not noticing that earlier.
— Krinkle
On 5 Aug 2015, at 17:12, Max Semenik maxsem.wiki@gmail.com wrote:
Already reported as https://phabricator.wikimedia.org/T108139 https://phabricator.wikimedia.org/T108139
On Wed, Aug 5, 2015 at 5:10 PM, Bartosz Dziewoński <matma.rex@gmail.com mailto:matma.rex@gmail.com> wrote: I think this announcement is missing one important tidbit:
If you have `document.write(…)` anywhere in your user JavaScript, **you will get a blank page**
On Thu, 06 Aug 2015 01:24:03 +0200, Krinkle krinklemail@gmail.com wrote:
TL:DR; Double-check your wiki's site scripts and your personal scripts
to ensure "document.write" is no longer used.
...
Check out the migration page for other deprecations and common issues you may encounter: https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)
I notice people have added document.write() migration advice to its "Good practices" section [1] (thanks! <3 ). There's other good advice there.
Our JavaScript coding conventions barely mentioned ResourceLoader, I added a "use the RL, Luke!" section [2] with a link to those Good practices.
Related, I added some tips on the somewhat black arts of RL debugging to Developing with ResourceLoader [3].
[1] https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_%28users%29#Go... [2] https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript [3] https://www.mediawiki.org/wiki/ResourceLoader/Developing_with_ResourceLoader...
Help will be appreciated @ https://phabricator.wikimedia.org/T108437 Em 07/08/2015 5:05 PM, "S Page" spage@wikimedia.org escreveu:
On Thu, 06 Aug 2015 01:24:03 +0200, Krinkle krinklemail@gmail.com wrote:
TL:DR; Double-check your wiki's site scripts and your personal scripts
to ensure "document.write" is no longer used.
...
Check out the migration page for other deprecations and common issues you may encounter: https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)
I notice people have added document.write() migration advice to its "Good practices" section [1] (thanks! <3 ). There's other good advice there.
Our JavaScript coding conventions barely mentioned ResourceLoader, I added a "use the RL, Luke!" section [2] with a link to those Good practices.
Related, I added some tips on the somewhat black arts of RL debugging to Developing with ResourceLoader [3].
[1]
https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_%28users%29#Go... [2] https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript [3]
https://www.mediawiki.org/wiki/ResourceLoader/Developing_with_ResourceLoader...
-- =S Page WMF Tech writer _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
On 7 Aug 2015, at 13:05, S Page spage@wikimedia.org wrote:
On Thu, 06 Aug 2015 01:24:03 +0200, Krinkle <krinklemail@gmail.com mailto:krinklemail@gmail.com> wrote:
TL:DR; Double-check your wiki's site scripts and your personal scripts to ensure "document.write" is no longer used. ... Check out the migration page for other deprecations and common issues you may encounter: https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users) https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)
I notice people have added document.write() migration advice to its "Good practices" section [1] (thanks! <3 ). There's other good advice there.
That's been there for a while actually :) I wrote that section in 2011.
-- Krinkle
Krinkle wrote:
TL:DR; Double-check your wiki's site scripts and your personal scripts to ensure "document.write" is no longer used.
Thanks for the detailed e-mail.
Search results from mwgrep on all public wikis: https://phabricator.wikimedia.org/P1832
These results seem to be limited to the "MediaWiki" namespace. I did a few 'insource:"document.write"' searches filtered to the User namespace via Special:Search and the results were surprisingly low. Suspiciously low, perhaps. Maybe somebody has already run a bot or script to clean up?
Do we know approximately how many users/user scripts are affected by this change across Wikimedia wikis?
Bartosz Dziewoński wrote:
I think this announcement is missing one important tidbit:
If you have `document.write(…)` anywhere in your user JavaScript, **you will get a blank page** on all pages of your wiki *, including the user JavaScript page you'd have to edit to fix it, until you disable JavaScript in your browser or ask an administrator to fix it for you.
Hmmm, I wonder if throwing a blank page counts as failing softly or failing loudly. :-) Depending on the number of users impacted by this change, https://phabricator.wikimedia.org/T108139 may not really be "Unbreak Now!"-level of priority. Ideally we'd fix/update most greppable instances of "document.write()" before deploying this type of breaking change; there's no rush, after all.
MZMcBride
wikitech-l@lists.wikimedia.org