Catrope has uploaded a new change for review.
https://gerrit.wikimedia.org/r/75270
Change subject: When a module is blocking (position=top), never defer its
execution
......................................................................
When a module is blocking (position=top), never defer its execution
There was a bug where if a module was in the top queue but had CSS,
its execution would be deferred until its CSS was ready. This would
cause the module's execution to occur after document ready and after
user scripts had run.
This is bad because top-loaded modules are supposed to be guaranteed
to run before document ready.
Fix this by skipping the wait-for-CSS logic when loading synchronously.
Top-loading modules' execution is now guaranteed to block loading the
rest of the page, but their CSS isn't guaranteed to be ready at this
point. Which is fine, because they shouldn't be measuring things in the
DOM before document ready anyway.
Change-Id: I5779cdef336be184741ad97ea84113eb7790dd39
---
M resources/mediawiki/mediawiki.js
1 file changed, 28 insertions(+), 22 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/70/75270/1
diff --git a/resources/mediawiki/mediawiki.js b/resources/mediawiki/mediawiki.js
index e36d9d0..f272b26 100644
--- a/resources/mediawiki/mediawiki.js
+++ b/resources/mediawiki/mediawiki.js
@@ -1018,30 +1018,36 @@
mw.messages.set(
registry[module].messages );
}
- // Make sure we don't run the scripts until all
(potentially asynchronous)
- // stylesheet insertions have completed.
- ( function () {
- var pending = 0;
- checkCssHandles = function () {
- // cssHandlesRegistered ensures
we don't take off too soon, e.g. when
- // one of the cssHandles is
fired while we're still creating more handles.
- if ( cssHandlesRegistered &&
pending === 0 && runScript ) {
- runScript();
- runScript = undefined;
// Revoke
- }
- };
- cssHandle = function () {
- var check = checkCssHandles;
- pending++;
- return function () {
- if (check) {
- pending--;
- check();
- check =
undefined; // Revoke
+ if ( $.isReady || registry[module].async ) {
+ // Make sure we don't run the scripts
until all (potentially asynchronous)
+ // stylesheet insertions have completed.
+ ( function () {
+ var pending = 0;
+ checkCssHandles = function () {
+ // cssHandlesRegistered
ensures we don't take off too soon, e.g. when
+ // one of the
cssHandles is fired while we're still creating more handles.
+ if (
cssHandlesRegistered && pending === 0 && runScript ) {
+ runScript();
+ runScript =
undefined; // Revoke
}
};
- };
- }() );
+ cssHandle = function () {
+ var check =
checkCssHandles;
+ pending++;
+ return function () {
+ if (check) {
+
pending--;
+ check();
+ check =
undefined; // Revoke
+ }
+ };
+ };
+ }() );
+ } else {
+ // We are in blocking mode, and so we
can't afford to wait for CSS
+ cssHandle = function () { return
function () { }; }; // noop
+ checkCssHandles = runScript; // Run
immediately
+ }
// Process styles (see also mw.loader.implement)
// * back-compat: { <media>: css }
--
To view, visit https://gerrit.wikimedia.org/r/75270
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5779cdef336be184741ad97ea84113eb7790dd39
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits