Page MenuHomePhabricator

Replace module
Open, LowPublic5 Estimate Story Points


Currently, the search page loads the module, which contains code for page parts that AdvancedSearch hides or replaces. To optimize JavaScript loading speed and avoid unwanted side effects, we should understand which parts of the module are still necessary, implement them in AdvancedSearch and then remove in the page load hook.

Event Timeline

Restricted Application added a project: TCB-Team. · View Herald TranscriptSep 19 2018, 5:09 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Lea_WMDE triaged this task as Low priority.Sep 25 2018, 9:29 AM
Lea_WMDE added a subscriber: Lea_WMDE.

The question is whether you can unload things. The js file in question is 60 lines long, so loading time should not be the problem, only potential bad interaction

Tobi_WMDE_SW set the point value for this task to 5.Mar 4 2019, 11:42 AM

Spot on, @Lea_WMDE! You can't unload (or rather "un-require") modules because that has the potential to send the dependency resolution algorithm of ResourceLoader into a frenzy of deadlocks and conflicts (when modules contradict each other about their requirements, esp. when they are transitive). So this ticket can be closed as "Invalid" or "Declined".

I had another look at the code in For better documentation & understanding, here is what it does on the search page and how it's related to AdvancedSearch:

  • Set the focus on the search field for browsers that don't support the autofocus HTML attribute. Since those browsers are very likely to not see the JavaScript anyway, I recommend deleting this code to save a few bytes in MediaWiki JavaScript. We should create a new ticket for that.
  • Toggle the checkboxes when clicking on the preset links (Article/Multimedia/Everything/Advanced). AdvancedSearch comes with its own preset handling, so that's a bit of dead code, but it only affects network speed and not CPU speed, as 95% of the code is event handling that is never executed.
  • Preserve search terms when clicking on the preset links link. Same effects on Network and CPU performance as above.
  • Change method from GET to POST when the "Save search preferences" is clicked. This is a behavior that AdvancedSearch should implement too, to avoid exposing the user token in the URL. Please create a new ticket for that, as that ticket has to be to estimated separately.
gabriel-wmde moved this task from Review to Done on the WMDE-FUN-Sprint-2019-03-04 board.