Skip to content

Conversation

adi-herwana-nus
Copy link
Contributor

Contains changes cherry-picked from #7889 (7 of 36 commits)

jQuery and jQuery UI

We're only using jQuery and jQuery UI (122.29 kB combined) for the reordering of achievements in the table in AchievementReordering. This PR removes the implicit global availability of jQuery and ensures both libraries are loaded on demand only when a user decides to reorder the achievements.

Ace

While Ace's mode scripts aren't huge, we are loading them all over the place. This PR ensures that modes are loaded on demand when we need them, e.g., only load ace-builds/src-noconflict/mode-r when we are loading R programming answers.

Other optimisations

  1. Trim moment-timezone data to only from 2014, when Coursemology has its first commit (reduced ~100 kB)

@adi-herwana-nus
Copy link
Contributor Author

KIV: we may be able to rework Achievement Reordering page in the future, and at the same time remove the jquery dependency entirely.

Screenshot 2025-05-14 at 14 29 51

Currently user switches between "reordering" and "not reordering" mode by the button on the top right. However, the reordering UI isn't that intrusive and we already auto save reordering whenever user drag and drop, so I think we can consider making the "reordering" mode of this page permanent.

- remove jQuery check from `wait_for_ajax` rspec helper
- lazy load jQuery, jQuery UI for achievement reordering page
- lazy load non-python language modes and removed jquery initializer
@adi-herwana-nus adi-herwana-nus force-pushed the phillmont/frontend-optimization-1 branch from ba312d4 to e6a6423 Compare May 14, 2025 06:34
@cysjonathan cysjonathan merged commit a8a9c6f into master May 14, 2025
14 checks passed
@cysjonathan cysjonathan deleted the phillmont/frontend-optimization-1 branch May 14, 2025 08:36
@purfectliterature
Copy link
Contributor

purfectliterature commented May 14, 2025

I considered that too. In fact, I tried removing the jQuery dependency completely but that meant rewriting the table since reordering with @hello-pangea/dnd will break display: tables. I decided not to move on with this because if I did, there would have been too many "low-level changes" in the original PR. I tried to keep the changes in the original PR be high-level so it's easier to review and merge.

Having the reordering available without switching is okay too if we remove jQuery. I didn't do that because I didn't want jQuery loading to bog down the page if someone comes in just to change one achievement's title.

The point with my changes to jQuery in the original PR is to reinforce that jQuery is only needed by the Achievements page. Previously, everyone thinks that it's still used somewhere by something somehow, carried over from when we SSR with Rails. Now, it's localised.

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.

3 participants