I'm having an issue with getting ResourceLoader to properly load the
Masonry library [1]. This issue was not present on MW 1.25 but is on MW
1.27. If I do the following:
$out->addModules( 'ext.masonrymainpage.libs' ); // or as dependency to base
$out->addModules( 'ext.masonrymainpage.base' );
Then I get the following error in my browser:
Uncaught Error: Module "jquery" is not loaded.
at require
(load.php?debug=true&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=ciafJ7Ly:12581)
at masonry.pkgd.js?c5dde:29
at masonry.pkgd.js?c5dde:39
require @
load.php?debug=true&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=ciafJ7Ly:12581
(anonymous) @ masonry.pkgd.js?c5dde:29
(anonymous) @ masonry.pkgd.js?c5dde:39
load.php?debug=true&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=ciafJ7Ly:11145
Use of "wgCategories" is deprecated. Use mw.config instead.
get @
load.php?debug=true&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=ciafJ7Ly:11145
(anonymous) @
load.php?debug=true&lang=en&modules=site&only=scripts&skin=vector&version=680c78b07fb0:273
However, if I load Masonry not from the ext.masonrymainpage.libs module,
but instead using OutputPage::addScript() then I have no issues:
global $wgServer, $wgExtensionAssetsPath;
$scriptURL =
"$wgServer/$wgExtensionAssetsPath/MasonryMainPage/masonry.pkgd.js";
$out->addScript( "<script type='text/javascript'
src='$scriptURL'></script>" );
$out->addModules( 'ext.masonrymainpage.base' );
Can anyone help me figure out how to do this the right way?
Thanks,
James
[1] https://github.com/desandro/masonry
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l