Skip to content

Remove jQuery #7142

@pablobm

Description

@pablobm

Is jQuery required in this project? The codebase is old so I'm sure it made sense for a long time, but I have the impression that now it's used for things already provided by browsers at very high level of compatibility.

Trying now, my browser loads 2.68 MB of uncompressed JS (617.35 kB compressed/transferred). Of that 285k (uncompressed) appears to be jQuery.

Dependencies that require JS:

  • jquery-ujs (22kB uncompressed): can't remember exactly what this includes. One thing is support for method="delete", etc which I think nowadays is implemented with Turbo, which we also load.
  • jquery.throttle-debounce: throttling/debouncing is old hat in JS. There must be a different library we can use that doesn't require jQuery.

Something potentially important that we'd be missing: delegated events. jQuery makes it easy to set events on elements that don't exist on the page yet, and these magically work when the element appears. Some refactoring might be required. Other, smaller libraries might help here.

If we were to decide to remove jQuery, I wouldn't expect it to happen all in one fell swoop, but rather incrementally: discouraging it from new code while slowly removing existing usage module by module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions