Skip to content

refine: remove unused on helper from website theme JS - #6143

Merged
max-sixty merged 2 commits into
mainfrom
refine/website-dead-on-helper
Aug 5, 2026
Merged

refine: remove unused on helper from website theme JS#6143
max-sixty merged 2 commits into
mainfrom
refine/website-dead-on-helper

Conversation

@prql-bot

@prql-bot prql-bot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

main.js is a single IIFE with no exports, so its on helper 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 through onscroll.

With on gone, nothing passes all = true any more, so select's all branch (return [...document.querySelectorAll(el)]) is unreachable too — the second commit drops it, leaving select as a one-line document.querySelector wrapper. The sole call site, select(".back-to-top"), already took the default all = false. select and onscroll are 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.

@prql-bot prql-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 selectreturn [...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.

@prql-bot

prql-bot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

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 all parameter and the querySelectorAll branch, so select is now const select = (el) => document.querySelector(el.trim());. The one call site, select(".back-to-top"), was already on the default path, and node --check plus prettier --check both pass on the result. PR description updated to cover both commits.

@max-sixty
max-sixty merged commit 4481574 into main Aug 5, 2026
35 checks passed
@max-sixty
max-sixty deleted the refine/website-dead-on-helper branch August 5, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants