Skip to content

Future of jQuery at GitLab

Internal notes: https://docs.google.com/document/d/1fkiD7cKen9HLTwMHjudCDAVZqeIOzG10uJvr_QDWTEk

Summary

  • We don't want to unnecessarily spend extra time refactoring jQuery code into non-jQuery code if the only purpose is to remove jQuery. The 87kb saved doesn't seem to be worth the effort. Preliminary search says there are 2105 instances of jQuery being used in 323 files.
  • We are about to introduce code splitting (next step after dispatcher refactor - https://gitlab.com/gitlab-org/gitlab-ce/issues/41341), so we should refactor some jQuery code to take advantage of code splitting. Loading jQuery on specific pages rather than on every page would give us the most return on investment, in terms of time.

Takeaways

  1. Refactor jQuery code to vanilla JS for code that are loaded on all pages, e.g. /behaviors/* (to prepare for code splitting)
  2. Don't write anymore code with jQuery
  3. Consider using jQuery slim (saves 17kb)

Action Items

  • Document takeaway 2 on our frontend docs
  • Create issue to address takeaway 1
  • Create issue to address takeaway 3
Edited by Clement Ho