refine: remove unused on helper from website theme JS - #6143
Conversation
prql-bot
left a comment
There was a problem hiding this comment.
Verified: main.js is a self-contained IIFE loaded on its own from baseof.html (<script src="{{ "/main.js" | relURL }}">), on was never assigned to a global, and no layout or other theme script references it — the removal is behaviour-preserving.
One follow-on, outside this diff: on was the only caller that ever passed all = true, so the all branch inside select — return [...document.querySelectorAll(el)] — is now unreachable for the same reason. The single remaining call is select(".back-to-top"), which takes the default all = false. If the intent is to clear the dead code rather than keep select general-purpose, that branch belongs in this PR too; happy to push the follow-up commit either way.
|
Took the follow-on — the PR's whole point is clearing dead code, so leaving a branch that can no longer be reached would be half a job. 699f611 drops the |
main.jsis a single IIFE with no exports, so itsonhelper is only reachable from inside that closure — and nothing there calls it. The one listener the file actually wires up is the back-to-top button, which goes throughonscroll.With
ongone, nothing passesall = trueany more, soselect'sallbranch (return [...document.querySelectorAll(el)]) is unreachable too — the second commit drops it, leavingselectas a one-linedocument.querySelectorwrapper. The sole call site,select(".back-to-top"), already took the defaultall = false.selectandonscrollare both still used and stay.Removing it leaves behaviour identical.
Found during the nightly survey of
web/website/themes/prql-theme/static/main.js. No test — the site has no JS test suite, and this is a pure removal of unreachable code.