Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.58k stars 799 forks source link

Remove jQuery dependency #16409

Open gravityrail opened 4 years ago

gravityrail commented 4 years ago

What follows is a list of files that we have detected jQuery-like syntax in, listed in approximate priority order.

Prioritisation was based on the following(rough) criteria:

In eliminating these uses of jQuery, you may find this web site useful: http://youmightnotneedjquery.com/

Files

The following list of files was generated using eslint. Don't forget, once you modify a file, to remove jquery as a dependency wherever that file was enqueued.

Front-end

Carousel

Tiled Gallery

Related Posts

Sharing Buttons

Gutenberg

Contact Forms

Contact Info Widget

EU Cookie Widget

Likes

Masterbar

Post by Email

Misc Shortcodes (rarely used)

Responsive Videos

Site Logo Control

Widget Visibility

Comics

VideoPress

Customizer

CSS Editor

Content Options

Customizer Utils

Simple Payments

Infinite Scroll

WP-Admin

It might not be worth bothering removing jQuery from wp-admin, as on these pages performance is less of an issue, and they prrrrobably enqueue jQuery no matter what you do.

Comment Likes

Just in Time Messages

Notices

Jetpack Settings

Connection

Deactivate warning

"Identity Crisis"

Gallery settings

Plugin Search (unused)

MISC

I don't yet know the scope of these:

dero commented 4 years ago

It might not be worth bothering removing jQuery from wp-admin, as on these pages performance is less of an issue, and they prrrrobably enqueue jQuery no matter what you do.

+1

jeherve commented 4 years ago

Noting that any effort in this direction will most likely help avoiding any conflicts that may come up when Core updates the version of jQuery bundled with WordPress:

davidlonjon commented 4 years ago

I'll have a go at

Contact Forms

dero commented 4 years ago

I'm starting to work on:

Tiled Gallery

gravityrail commented 4 years ago

@dero @davidlonjon - if you're working on something please update the description to put your name on it, and if possible a link to your PR, so we don't overlap.

gravityrail commented 4 years ago

I'll have a go at

Contact Forms

  • modules/contact-form/js/editor-view.js
  • modules/contact-form/js/grunion-admin.js

@davidlonjon Just make sure you aren't removing jQuery as a dep from anything shown in wp-admin. I am not really interested in wp-admin right now - only front-end code.

davidlonjon commented 4 years ago

I'll have a go at Contact Forms

  • modules/contact-form/js/editor-view.js
  • modules/contact-form/js/grunion-admin.js

@davidlonjon Just make sure you aren't removing jQuery as a dep from anything shown in wp-admin. I am not really interested in wp-admin right now - only front-end code.

Ok thanks for the feedback. For info I have not done much work on this as I refocused my attention on our other project.

sgomes commented 4 years ago

Moved modules/comment-likes/comment-like-count.js to the wp-admin section, as it doesn't appear to be used outside of there. Dropping ongoing work there and picking up something else.

gravityrail commented 4 years ago

Noting here that we should use the wp-dom-ready package instead of jQuery.ready

https://developer.wordpress.org/block-editor/packages/packages-dom-ready/

Aurorum commented 4 years ago

I had a go at modules/shortcodes/js/gist.js in #16700. :)

sgomes commented 4 years ago

@gravityrail: Adding a note here that once the plan we've been discussing in https://github.com/Automattic/jetpack/pull/16592#discussion_r463200046 has been finalised, we should probably document it and add a link to it on this issue.

jeherve commented 4 years ago

Noting that the modules/widgets/eu-cookie-law/eu-cookie-law-admin.js file currently generates a warning with Core's Enable jQuery Migrate Helper plugin:

image

Same in modules/calypsoify/mods.js: jQuery.fn.load() is deprecated

It may be worth prioritizing these files (and others that trigger such warnings) accordingly.

jeherve commented 1 week ago

@sgomes I know you had worked on removing jQuery dependencies at some point. Is that something that's still on you radar today?

sgomes commented 1 week ago

@jeherve I haven't looked at this in a while, but I seem to recall jQuery usage was fairly small at this point, outside of wp-admin (which is out of scope, as I see it).

Perhaps a new audit of jQuery usage in Jetpack is needed at this point, but I won't be able to pick that up in the foreseeable future 😕