Create common.js#3
Conversation
Reviewer's GuideAdds a new common.js file that aggregates and loads a large set of user scripts and gadgets from Wikidata using importScript and mw.loader.load, effectively centralizing custom tooling setup for the user. Sequence diagram for loading user gadgets via common_jssequenceDiagram
actor User
participant Browser
participant MediaWiki_Server
participant Common_js
participant User_Scripts_Aggregate
User->>Browser: Open Wikidata page
Browser->>MediaWiki_Server: Request page and user scripts
MediaWiki_Server-->>Browser: HTML + common_js reference
Browser->>Common_js: Execute common_js
Common_js->>MediaWiki_Server: importScript User_Vvekbv_recoin_id_js
MediaWiki_Server-->>Browser: Response with recoin_id_js
Common_js->>MediaWiki_Server: mw_loader_load ScriptInstaller_js
MediaWiki_Server-->>Browser: Response with ScriptInstaller_js
Common_js->>User_Scripts_Aggregate: importScript and mw_loader_load multiple gadgets
User_Scripts_Aggregate-->>Browser: Register UI enhancements and tools
Browser-->>User: Enhanced Wikidata interface with loaded gadgets
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- There are multiple duplicate loads of the same scripts (e.g.,
thirdpartyformatters,labelcollect,metaclass-check,WikidataComplete,relateditems, etc. via bothmw.loader.loadandimportScript); consider consolidating to a single import per script to avoid redundant network requests and potential double‑execution. - Some loader URLs appear inconsistent or malformed (for example the
Luca.favorido/linkypop.jsline lacks the?title=...&action=raw&ctype=...pattern used elsewhere); it would be good to standardize and verify eachmw.loader.loadURL to ensure they resolve correctly. - Given the very large number of scripts loaded unconditionally, you may want to group related imports and gate some of them behind feature checks or conditions to reduce page load overhead and make future maintenance easier.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There are multiple duplicate loads of the same scripts (e.g., `thirdpartyformatters`, `labelcollect`, `metaclass-check`, `WikidataComplete`, `relateditems`, etc. via both `mw.loader.load` and `importScript`); consider consolidating to a single import per script to avoid redundant network requests and potential double‑execution.
- Some loader URLs appear inconsistent or malformed (for example the `Luca.favorido/linkypop.js` line lacks the `?title=...&action=raw&ctype=...` pattern used elsewhere); it would be good to standardize and verify each `mw.loader.load` URL to ensure they resolve correctly.
- Given the very large number of scripts loaded unconditionally, you may want to group related imports and gate some of them behind feature checks or conditions to reduce page load overhead and make future maintenance easier.
## Individual Comments
### Comment 1
<location> `common.js:40` </location>
<code_context>
+
+mw.loader.load( '//www.wikidata.org/w/index.php?title=User%3AData-Complete-Gadget%2FWikidataComplete.js&action=raw&ctype=text%2Fjavascript' );
+
+mw.loader.load('//www.wikidata.org/wiki/User:Luca.favorido/linkypop.js&action=raw&ctype=text/javascript');
+importScript('User:Pigsonthewing/vector.js'); //Linkback: [[User:Pigsonthewing/vector.js]]
+importScript('User:TomT0m/LexToWiktionary.js'); //Linkback: [[User:TomT0m/LexToWiktionary.js]]
</code_context>
<issue_to_address>
**issue (bug_risk):** The `linkypop.js` loader URL is malformed and likely won’t load correctly.
This call differs from the others: it uses `/wiki/User:.../linkypop.js&action=raw...` instead of the `w/index.php?title=...&action=raw&ctype=text/javascript` pattern, and is missing the `?` before the query string. Please switch it to the standard `w/index.php?title=User%3ALuca.favorido%2Flinkypop.js&action=raw&ctype=text%2Fjavascript` form or confirm that the current URL actually returns the raw JS as intended.
</issue_to_address>
### Comment 2
<location> `common.js:45` </location>
<code_context>
+importScript('User:TomT0m/LexToWiktionary.js'); //Linkback: [[User:TomT0m/LexToWiktionary.js]]
+importScript('User:TomT0m/queries.js'); //Linkback: [[User:TomT0m/queries.js]]
+importScript('User:Pigsonthewing/common.js'); //Linkback: [[User:Pigsonthewing/common.js]]
+importScript('User:Vvekbv/recoin id.js'); //Linkback: [[User:Vvekbv/recoin id.js]]
+importScript('User:Magnus Manske/wd edit.js'); //Linkback: [[User:Magnus Manske/wd edit.js]]]
+importScript('User:JonnyJD/consistency check.js'); //Linkback: [[User:JonnyJD/consistency check.js]]
</code_context>
<issue_to_address>
**issue (bug_risk):** The `recoin id.js` path looks inconsistent with the earlier `recoin_id.js` import and may be a typo.
Here you import `User:Vvekbv/recoin id.js` (with a space), whereas earlier you import `User:Vvekbv/recoin_id.js`. If the underscore version is the intended title, this will fail to load; if both pages exist, you’ll load two different scripts. Please standardize on the correct page name.
</issue_to_address>
### Comment 3
<location> `common.js:143` </location>
<code_context>
+importScript('User:The-erinaceous-one/Gadget-relateditems.js'); //Linkback: [[User:The-erinaceous-one/Gadget-relateditems.js]] Added by Script installer
+importScript('User:Lockal/Gadget-relateditems.js'); //Linkback: [[User:Lockal/Gadget-relateditems.js]] Added by Script installer
+importScript('User:Magnus Manske/missing props.js'); //Linkback: [[User:Magnus Manske/missing props.js]] Added by Script installer
+importScript('User:Husky/thirdpartyformatters.js'); //Linkback: [[User:Husky/thirdpartyformatters.js]] Added by Script installer
+importScript('User:Magnus Manske/wdutil.js'); //Linkback: [[User:Magnus Manske/wdutil.js]] Added by Script installer
+importScript('User:Magnus Manske/wikidata useful.js'); //Linkback: [[User:Magnus Manske/wikidata useful.js]] Added by Script installer
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Several scripts appear to be loaded more than once, which is unnecessary and may cause side effects.
For example, `User:Husky/thirdpartyformatters.js` is imported both near the top and bottom, and there are multiple imports of labelcollect/classification variants. These duplicates can cause functions to be redefined or event handlers attached multiple times, leading to subtle bugs and slower page loads. Please deduplicate so each script is imported only once.
Suggested implementation:
```javascript
importScript('User:The-erinaceous-one/Gadget-relateditems.js'); //Linkback: [[User:The-erinaceous-one/Gadget-relateditems.js]] Added by Script installer
```
1. Search the rest of `common.js` for any additional occurrences of:
- `importScript('User:Husky/thirdpartyformatters.js');`
- labelcollect/classification-related scripts (e.g., `labelcollect`, `labelcollect-classification` variants).
2. For each script that appears multiple times, decide on a single canonical import location (typically near the top or grouped with similar tools) and remove all other duplicate `importScript`/`mw.loader.load` calls.
3. Ensure that each logical script (by page title, e.g., `User:Foo/bar.js`) is imported exactly once across the entire file, regardless of whether it uses `importScript` or `mw.loader.load`.
</issue_to_address>
### Comment 4
<location> `common.js:54-63` </location>
<code_context>
+//Script to warn about conflicting superclasses on instance/subclass statements
</code_context>
<issue_to_address>
**suggestion (bug_risk):** You’re loading the conflicting superclass script twice via different mechanisms/paths.
You load `User:JesseW/conflicting_superclass_warnings.js` via `mw.loader.load(...)` and later `User:JesseW/conflicting superclass warnings.js` via `importScript(...)`. If these refer to the same script (or duplicated code under different titles), it will run twice, which can cause duplicate initialization and event handlers. Please consolidate to a single canonical import.
Suggested implementation:
```javascript
```
1. Ensure that the other occurrence of this script (likely `importScript('User:JesseW/conflicting superclass warnings.js');`) remains in the file and serves as the single canonical import.
2. If you prefer the underscore form as canonical (`conflicting_superclass_warnings.js`), update that remaining `importScript(...)` call to use that exact title, e.g.:
`importScript('User:JesseW/conflicting_superclass_warnings.js');`
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| mw.loader.load( '//www.wikidata.org/w/index.php?title=User%3AData-Complete-Gadget%2FWikidataComplete.js&action=raw&ctype=text%2Fjavascript' ); | ||
|
|
||
| mw.loader.load('//www.wikidata.org/wiki/User:Luca.favorido/linkypop.js&action=raw&ctype=text/javascript'); |
There was a problem hiding this comment.
issue (bug_risk): The linkypop.js loader URL is malformed and likely won’t load correctly.
This call differs from the others: it uses /wiki/User:.../linkypop.js&action=raw... instead of the w/index.php?title=...&action=raw&ctype=text/javascript pattern, and is missing the ? before the query string. Please switch it to the standard w/index.php?title=User%3ALuca.favorido%2Flinkypop.js&action=raw&ctype=text%2Fjavascript form or confirm that the current URL actually returns the raw JS as intended.
| importScript('User:TomT0m/LexToWiktionary.js'); //Linkback: [[User:TomT0m/LexToWiktionary.js]] | ||
| importScript('User:TomT0m/queries.js'); //Linkback: [[User:TomT0m/queries.js]] | ||
| importScript('User:Pigsonthewing/common.js'); //Linkback: [[User:Pigsonthewing/common.js]] | ||
| importScript('User:Vvekbv/recoin id.js'); //Linkback: [[User:Vvekbv/recoin id.js]] |
There was a problem hiding this comment.
issue (bug_risk): The recoin id.js path looks inconsistent with the earlier recoin_id.js import and may be a typo.
Here you import User:Vvekbv/recoin id.js (with a space), whereas earlier you import User:Vvekbv/recoin_id.js. If the underscore version is the intended title, this will fail to load; if both pages exist, you’ll load two different scripts. Please standardize on the correct page name.
| importScript('User:The-erinaceous-one/Gadget-relateditems.js'); //Linkback: [[User:The-erinaceous-one/Gadget-relateditems.js]] Added by Script installer | ||
| importScript('User:Lockal/Gadget-relateditems.js'); //Linkback: [[User:Lockal/Gadget-relateditems.js]] Added by Script installer | ||
| importScript('User:Magnus Manske/missing props.js'); //Linkback: [[User:Magnus Manske/missing props.js]] Added by Script installer | ||
| importScript('User:Husky/thirdpartyformatters.js'); //Linkback: [[User:Husky/thirdpartyformatters.js]] Added by Script installer |
There was a problem hiding this comment.
suggestion (bug_risk): Several scripts appear to be loaded more than once, which is unnecessary and may cause side effects.
For example, User:Husky/thirdpartyformatters.js is imported both near the top and bottom, and there are multiple imports of labelcollect/classification variants. These duplicates can cause functions to be redefined or event handlers attached multiple times, leading to subtle bugs and slower page loads. Please deduplicate so each script is imported only once.
Suggested implementation:
importScript('User:The-erinaceous-one/Gadget-relateditems.js'); //Linkback: [[User:The-erinaceous-one/Gadget-relateditems.js]] Added by Script installer- Search the rest of
common.jsfor any additional occurrences of:importScript('User:Husky/thirdpartyformatters.js');- labelcollect/classification-related scripts (e.g.,
labelcollect,labelcollect-classificationvariants).
- For each script that appears multiple times, decide on a single canonical import location (typically near the top or grouped with similar tools) and remove all other duplicate
importScript/mw.loader.loadcalls. - Ensure that each logical script (by page title, e.g.,
User:Foo/bar.js) is imported exactly once across the entire file, regardless of whether it usesimportScriptormw.loader.load.
| //Script to warn about conflicting superclasses on instance/subclass statements | ||
| mw.loader.load('//www.wikidata.org/w/index.php?title=User:JesseW/conflicting_superclass_warnings.js&action=raw&ctype=text/javascript'); // [[User:JesseW/conflicting_superclass_warnings.js]] | ||
|
|
||
| importScript('User:YMS/labelcollect2.js'); //Linkback: [[User:YMS/labelcollect2.js]] Added by Script installer | ||
|
|
||
| importScript('User:TomT0m/classification/sandbox.js'); //Linkback: [[User:TomT0m/classification/sandbox.js]] Added by Script installer | ||
| importScript('User:Lectrician1/metaclass-check.js'); //Linkback: [[User:Lectrician1/metaclass-check.js]] Added by Script installer | ||
| importScript('User:Daniel Mietchen/wikidp.js'); //Linkback: [[User:Daniel Mietchen/wikidp.js]] Added by Script installer | ||
| importScript('User:Wd-Ryan/quickpresets settings.js'); //Linkback: [[User:Wd-Ryan/quickpresets settings.js]] Added by Script installer | ||
| importScript('User:Fnielsen/EntityShape.js'); //Linkback: [[User:Fnielsen/EntityShape.js]] Added by Script installer |
There was a problem hiding this comment.
suggestion (bug_risk): You’re loading the conflicting superclass script twice via different mechanisms/paths.
You load User:JesseW/conflicting_superclass_warnings.js via mw.loader.load(...) and later User:JesseW/conflicting superclass warnings.js via importScript(...). If these refer to the same script (or duplicated code under different titles), it will run twice, which can cause duplicate initialization and event handlers. Please consolidate to a single canonical import.
Suggested implementation:
- Ensure that the other occurrence of this script (likely
importScript('User:JesseW/conflicting superclass warnings.js');) remains in the file and serves as the single canonical import. - If you prefer the underscore form as canonical (
conflicting_superclass_warnings.js), update that remainingimportScript(...)call to use that exact title, e.g.:
importScript('User:JesseW/conflicting_superclass_warnings.js');
Summary by Sourcery
New Features: