Opened 21 months ago
Last modified 16 months ago
#54172 assigned enhancement
Twenty Fifteen: Replace frontend jQuery usage with vanilla JS
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Bundled Theme | Keywords: | has-patch |
Focuses: | javascript | Cc: |
Description
Using jQuery for a few simple JS interactions in WordPress themes is a common performance problem, which is in most cases relatively straightforward to address: Vanilla JavaScript has for the better part of a decade included enough APIs that work across all popular browsers so that the remaining benefits of jQuery are around a few utility functions, that could be re-implemented in a few lines of code. Using jQuery for such simple use-cases results in around 80% more JS code being loaded in the frontend.
This ticket focuses on removing jQuery as a frontend dependency for Twenty Fifteen - specifically the frontend, as for example in the Customizer jQuery is loaded anyway (and performance is a bit less of a concern there).
Also see #54171, which does the same for Twenty Twelve.
Change History (5)
This ticket was mentioned in PR #1682 on WordPress/wordpress-develop by adamsilverstein.
21 months ago
#1
- Keywords has-patch added; needs-patch removed
#2
@
21 months ago
- Summary changed from Replace frontend jQuery usage with vanilla JS in Twenty Fifteen to Twenty Fifteen: Replace frontend jQuery usage with vanilla JS
16 months ago
#3
Adding a note that after these changes, the JS will no longer work correctly in IE 11. I'm not sure whether this is a concern, given that on the one hand we've deprecated it, but on the other hand we may want to preserve this theme working correctly in older versions of WordPress and their supported browsers.
felixarntz commented on PR #1682:
16 months ago
#4
@sgomes Thanks for the review! I addressed your feedback via code updates and comments above.
#5
@
16 months ago
Note that the implementation for this depends on whether we will drop IE support in the theme or not. The discussion around this should be centralized in https://core.trac.wordpress.org/ticket/55126#comment:2, which does the same for Twenty Sixteen.
Trac ticket: https://core.trac.wordpress.org/ticket/54172