Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
GitLab Community Edition
GitLab Community Edition
  • Project
    • Project
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
    • Locked Files
  • Issues 11,041
    • Issues 11,041
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 666
    • Merge Requests 666
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • GitLab.org
  • GitLab Community EditionGitLab Community Edition
  • Issues
  • #23022

Closed
Open
Opened Oct 05, 2016 by Mike Greiling@mikegreiling 9 of 24 tasks completed9/24 tasks
  • Report abuse
  • New issue
Report abuse New issue

[meta] Eliminate jQuery library use in favor of modern alternatives.

Goals

jQuery has served its purpose well for a long time, ironing out the wrinkles between shoddy JavaScript and DOM implementations across the popular browsers of its day. However, we now live in a post-IE8 world, and much of what jQuery handled for us can now be done natively without loading a 250k (85k minimized) library.

Our aim with this meta-issue is to guide the eventual deprecation of this library in favor of Vue.js, complimented with other light utility libraries, polyfills, shims, and native function calls.

Process

  1. Update frontend guidelines.

    • emphasize native solutions and discourage jQuery use wherever possible
      • prefer document.querySelectorAll over jQuery selectors
      • prefer es2015 standards like for .. of over $.each()
    • link to resources for jQuery alternatives (e.g. youmightnotneedjquery.com)
    • link to Vue.js and es2015 learning resources for new contributors
    • forbid all use of jQuery within Vue.js components
  2. Triage and replace all jQuery-based libraries with ones which don't rely on jQuery.

    • remove jquery-ui (#18437 (closed))
      • remove jquery-ui/autocomplete
      • remove jquery-ui/datepicker
      • remove jquery-ui/draggable
      • remove jquery-ui/effect-highlight
      • remove jquery-ui/sortable
    • remove select2 in favor of gl-dropdown (#22223 (closed))
    • replace jquery.cookie with js.cookie (@mikegreiling !7085 (merged))
    • replace jquery.timeago with timeago.js (@ClemMakesApps #21793 (closed) - !6274 (merged))
    • replace / remove jquery.nicescroll
    • remove jquery.endless-scroll
    • remove jquery.highlight
    • remove jquery.waitforimages
    • remove jquery.atwho
    • remove jquery.scrollTo
    • remove jquery.turbolinks (after all event binding has been migrated off of jQuery)
    • remove jquery_ujs
    • remove jquery.ba-resize
  3. Refactor uses of jQuery selectors with document.querySelectorAll and iterate with for .. of. This should cover the vast bulk of jQuery usage.

  4. Replace all jQuery event binding ($.on(), $.off(), $.ready(), $.click(), $(function() { /* ... */ }), etc with el.addEventListener() and el.removeEventListener().

    • polyfill window.CustomEvent for IE (@filipa #24018 (closed) - !7204 (closed))
  5. Replace all jQuery .animate() calls with CSS3 animations. This should be both lighter and more performant and they are available in 100% of browsers GitLab currently supports.

  6. Replace all jQuery AJAX calls ($.get(), $.post(), $.getJSON(), $.ajax(), etc.) with a Promise-based library (e.g. axios)
    Native Promise is available in es2015 (with async/await on the way) and it will soon be the de facto standard over callback-based asynchronous function calls.

    • Issue #24011

This is a long term goal. jQuery has been deeply integrated with our frontend code from the beginning, so this will be a slow systematic process. But we need to start moving in the right direction.

Related issues

Assignee
Assign to
Epic
None
Milestone
None
Assign milestone
Time tracking
None
Due date
No due date
2
Labels
frontend meta
Assign labels
  • View project labels
Reference: gitlab-org/gitlab-ce#23022