Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking: JS modernization #3590

Closed
17 tasks done
bmesuere opened this issue May 3, 2022 · 2 comments · Fixed by #4879
Closed
17 tasks done

Tracking: JS modernization #3590

bmesuere opened this issue May 3, 2022 · 2 comments · Fixed by #4879
Assignees
Labels
chore Repository/build/dependency maintenance low priority Thing we want to see implemented at some point student Things summer interns can do tracking A Tracking issue

Comments

@bmesuere
Copy link
Member

bmesuere commented May 3, 2022

The goal of this issue is to track the "older" parts of our JavaScript code. There are 3 separate parts:

  • Getting rid of jQuery: this is a big library and not really needed on the modern web
  • Getting rid of the old application.js file: this will unify our build setup to only use the application pack
  • Migrate to typescript: better type checking

jQuery

  • The bootstrap token-field and typeahead still depend on jQuery. This is only used in the course label edit. course_membership.js: replace with webcomponent #4083
  • Almost all views contain code to initialize something that is wrapped in $(function() {}). This can probably be replaced by a jQuery-less equivalent Remove jquery usage for detecting if the dom is ready #3692
  • jQuery in the rails views
  • A lot of old JS code still uses jQuery. I think there a limited number of uses:
    • Selecting elements: can easily be replaced by native JS
    • Fetching: can also be replaced by a fetch
    • Events: should also be possible to refactor without too many issues
    • Adding HTML to pages, mostly by converting strings to html elements. There is no easy replacement for this, but the template system from lit could be reused here.

application.js

@bmesuere bmesuere added the low priority Thing we want to see implemented at some point label May 3, 2022
@bmesuere bmesuere added this to Roadmap May 3, 2022
@bmesuere bmesuere moved this to Unplanned in Roadmap May 3, 2022
@bmesuere bmesuere moved this from Unplanned to Todo in Roadmap May 3, 2022
@bmesuere bmesuere added the chore Repository/build/dependency maintenance label May 3, 2022
@jorg-vr jorg-vr self-assigned this Jun 3, 2022
@jorg-vr jorg-vr moved this from Todo to In Progress in Roadmap Jun 3, 2022
@bmesuere bmesuere added the student Things summer interns can do label Jun 12, 2022
@bmesuere
Copy link
Member Author

If #4189 gets merged, the ace editor is the only remaining asset in application.old.js. We use an (outdated) rails gem to add support using the sprockets pipeline. The problem with this library is that it contains A LOT of plugins to support all languages. These are loaded on demand (by file name) to keep the default package size small-ish.

There are a number of alternatives to remove this last remaining entry

  • use a hosted CDN version of the editor: we try to avoid this, should be the last resort
  • find an alternative rails integration: I haven't found one
  • bundle everything into a single file with our webpack pipeline: the file size will be huge
  • vendor it: manually in the public folder or by adding it to our package file and copy the files to the public folder in a build step (also see https://github.com/ajaxorg/ace-builds/)
  • use a different editor. For papyros we use codemirror, for dolos we use monaco.

If this is done, the old application.js file can be removed but this also means that the sprockets gem and its config and deployment stuff can probably be removed.

@bmesuere
Copy link
Member Author

As an update to my previous comment: Sprockets is still used for the newer JS as well, so it can't be removed. What we can do is leave ace as is, but rename the file from application_old to ace editor and only include it where needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Repository/build/dependency maintenance low priority Thing we want to see implemented at some point student Things summer interns can do tracking A Tracking issue
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants