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 mediawiki.special.search. For better documentation & understanding, here is what it does on the search page and how it's related to AdvancedSearch:
- 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.