Skip to content

Remove some jQuery - #4097

Merged
handeyeco merged 6 commits into
mainfrom
rm-jquery
Aug 19, 2026
Merged

Remove some jQuery#4097
handeyeco merged 6 commits into
mainfrom
rm-jquery

Conversation

@handeyeco

@handeyeco handeyeco commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary:

Inspired by this Slack convo

We don't need jQuery as much today as we did back in the day. I asked the LLM to remove some low-risk uses of jQuery and this is what it did.

@handeyeco handeyeco self-assigned this Aug 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

npm Snapshot

Want to try this PR's changes before it merges? Comment /snapshot below and we'll publish an npm snapshot you can install right away.

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Size Change: +139 B (+0.03%)

Total Size: 519 kB

📦 View Changed
Filename Size Change
packages/perseus-editor/dist/es/index.js 106 kB +27 B (+0.03%)
packages/perseus/dist/es/index.js 203 kB +112 B (+0.06%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.6 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 6.31 kB
packages/math-input/dist/es/index.js 98.6 kB
packages/math-input/dist/es/strings.js 1.63 kB
packages/perseus-core/dist/es/index.item-splitting.js 13.1 kB
packages/perseus-core/dist/es/index.js 28.3 kB
packages/perseus-linter/dist/es/index.js 10.1 kB
packages/perseus-score/dist/es/index.js 9.86 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/strings.js 12.9 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.12 kB

compressed-size-action

@handeyeco handeyeco changed the title remove some jQuery Remove some jQuery Aug 19, 2026
function findChildOrAdd(elem: HTMLElement, className: string): HTMLElement {
const child = elem.querySelector<HTMLElement>("." + className);
if (child) {
return child;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This confused me at first, but it just flipped the logic: instead of exiting early when there is no child, it exits early when there is a child.

@handeyeco
handeyeco marked this pull request as ready for review August 19, 2026 20:12
@handeyeco
handeyeco requested review from a team August 19, 2026 20:12

@jeremywiebe jeremywiebe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Pretty cool! Thanks

textarea.focus();
textarea.setSelectionRange(1, 1);
// NOTE: we use `fireEvent` because userEvent.paste doesn't go
// through the jQuery-bound paste listener, but fireEvent does.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Well this is a nice side-benefit that we can switch this!

"katex": "0.11.1",
"mafs": "^0.19.0",
"tiny-invariant": "catalog:prodDeps",
"jquery": "catalog:prodDeps"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does this really catch all remaining uses of jQuery in this editor package? Awesome!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What do you think about converting this to a modern React ref, which would then relieve us of needing the ReactDOM.findDOMNode(this.refs.graphieDiv); above?

Comment thread knip.config.ts
Comment on lines -55 to -58
// WB Themeing support comes via CSS variables that are imported from
// this tokens package and are included from
// .storybook/styles/shared.css
"@khanacademy/wonder-blocks-tokens",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this related to the jQuery removal?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't know what was up. My original commit failed the Knip check: https://github.com/Khan/perseus/actions/runs/32293020676/job/96197933830

Removing that line passed the Knip check. I can try to add it back if you think we need it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nah, we can remove it. We have imports of this package in perseus-editor, so I think the comment is invalid anyways.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried to add it back and got:

Configuration issues (1)
Unused item in ignoreDependencies: @khanacademy/wonder-blocks-tokens
✂️  Excellent, Knip found no issues.

Kind of mixed signals...

@handeyeco
handeyeco merged commit 1a06aad into main Aug 19, 2026
10 checks passed
@handeyeco
handeyeco deleted the rm-jquery branch August 19, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants