Project

General

Profile

Actions

Feature #44757

open

Remove the dependency on jQuery UI

Feature #44757: Remove the dependency on jQuery UI

Added by Go MAEDA about 12 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Third-party libraries
Resolution:

Description

Redmine loads jQuery UI on every page, but uses only part of its features: the date picker, autocomplete, sortable lists, two effects, the progress bar, the resizable columns of the Gantt chart, tooltips and dialogs. jQuery UI is also in maintenance-only mode. Some of these features, namely the date picker, the progress bar and modal dialogs, are now provided by the browser, and the others can be implemented with Stimulus controllers, plain JavaScript and CSS.

The attached patches make these replacements and then stop loading jQuery UI. Pages no longer load 255 KB of JavaScript and 32 KB of CSS, and the JavaScript in Redmine moves further towards Stimulus.

Because there are 12 patches and some of them are large, they are attached as a single archive, remove-jquery-ui-patches.tar.gz. They can be applied in order with:

tar xzf remove-jquery-ui-patches.tar.gz
git am remove-jquery-ui-patches/*.patch

The patches are:

  1. Remove the jQuery UI datepicker in favor of the native date input
  2. Replace the jQuery UI autocomplete with a Stimulus controller
  3. Replace the jQuery UI sortable with a Stimulus controller
  4. Replace the jQuery UI switchClass with classList
  5. Replace the jQuery UI highlight effect with a CSS animation
  6. Replace the jQuery UI progressbar with the native progress element
  7. Replace the jQuery UI resizable with Pointer Events in the gantt column controller
  8. Replace the jQuery UI tooltip with a Stimulus controller
  9. Replace the jQuery UI dialog with the native dialog element
  10. Stop loading jQuery UI on every page
  11. Upgrade the bundled jQuery UI to 1.14.2
  12. Show hover tooltips on the workflow page

Changes for users

  • Sortable lists, such as trackers, issue statuses and the blocks of My page, and the columns of the Gantt chart can also be reordered and resized on touch devices.
  • Tooltips are also shown for content loaded by Ajax, which previously showed the browser's tooltip.
  • The cells of the workflow page show the "old status ยป new status" title in the same tooltip as other elements, instead of the browser's tooltip. The no-tooltip class was added to them in #35034 because the jQuery UI tooltip, which was set up on each element with a title at page load, made the page very slow with many statuses (#34247). The new tooltip works through event delegation, so its cost does not depend on the number of elements. With 106 statuses (33,814 cells with a title), scripting takes about 180 ms both before and after the change, while removing no-tooltip with the jQuery UI tooltip took 343 seconds.
  • Dialogs can no longer be moved by dragging the title bar. Modal dialogs in most web applications cannot be moved either, and this should rarely be needed, because the page behind them cannot be used while they are open.

Changes for plugins and themes

jQuery UI is still bundled, but is no longer loaded by Redmine. If it were removed now, each plugin that uses it would have to include its own copy, and plugins on the same page could load different versions of it. Plugins that use jQuery UI directly need to load the bundled one:

javascript_include_tag 'jquery-ui.min'
stylesheet_link_tag 'jquery/jquery-ui'

The file names have no version, so they do not need to be changed when the bundled jQuery UI is upgraded. The 11th patch upgrades it to 1.14.2, so plugins only need to be checked once against both changes. This supersedes #44739, whose changes to Redmine's own code are no longer needed. The bundled jQuery UI will be removed in a future version of Redmine.

The following functions keep working without jQuery UI, so plugins that use only them do not need to load it. They have these limitations:

  • showModal and hideModal now open and close a native <dialog>, so the dialogclose event is no longer triggered.
  • observeAutocompleteField and multipleAutocompleteField support only a URL as the source and the select callback.
  • $.fn.positionedItems supports only the items and handle options.

calendar_for and include_calendar_headers_tags now do nothing, because date fields use the native date picker. They are deprecated and will be removed in Redmine 8.0.

The following functions are removed:

  • setupHoverTooltips and removeHoverTooltips, which are no longer needed because tooltips work through event delegation
  • datepickerFallback and beforeShowDatePicker, which were used only by the jQuery UI date picker fallback

The following CSS classes are renamed:

Before After
.ui-dialog, .ui-dialog-titlebar, .ui-dialog-content dialog.modal, .modal-header, .modal-content
.ui-tooltip .hover-tooltip
.ui-autocomplete .autocomplete-listbox
tr.ui-sortable-helper .sortable-item-dragging
.dragging (My page) .sortable-dragging
.ui-resizable-e (Gantt chart) .gantt-column-resizer
div.ui-progressbar progress

Files


Related issues 1 (1 open — 0 closed)

Related to Redmine - Feature #44739: Upgrade jQuery UI to 1.14.2NewGo MAEDAActions

Updated by Go MAEDA about 12 hours ago Actions #1

Actions

Also available in: PDF Atom