Open adamsilverstein opened 3 years ago
This idea seems reasonable (maybe even the responsible thing to do) to me, bonus points if the warning message is friendly and inviting instead of scary :)
Yes, I had it on my to do list but if you want to work on it that would be great.
There is also the scenario where the user tries to include and enqueue their own version of jQuery -that should block theme upload.
There is also the scenario where the user tries to include and enqueue their own version of jQuery -that should block theme upload.
Good point @carolinan - so would we detect the actual inclusion of jquery with the theme, or the enqueueing, or both? I guess some themes might try to enqueue from a CDN, or is that already covered by a different check?
I'm going to open a separate issue for this ^^ so I can keep my work here focused on the narrow case of warning about enqueueing jquery on the front end.
Both. There is a CDN check but it is limited to a list of well known CDN's. https://github.com/WordPress/theme-check/blob/master/checks/class-cdn-check.php#L44
@carolinan finally found time to get back to this and opened https://github.com/WordPress/theme-check/pull/423 to address.
I tested this locally to verify it works :) Still have some questions about the implementation which I will leave as comments on the PR code
Also, welcome any suggestions to improve wording/language to make it more "friendly and inviting instead of scary :)"
@carolinan this is ready for review whenever you have a chance.
While it has been widely known that you might not need jQuery for most of your interactive theme features, jQuery is still a common JavaScript dependency found in WordPress themes - for example, 7 out of the 11 default themes since Twenty Ten use jQuery in the frontend.
A recent analysis of the performance impact of using jQuery in WordPress themes determined that jQuery is the most common JavaScript-based performance problem in themes and that Removing jQuery may lead to 80% less JavaScript load. According to the analysis, most themes can easily substitute (modern) vanilla JavaScript and remove their reliance on jQuery with only minor changes.
To help theme developers make better choices in the future, I would like to add a warning to the theme-check plugin when themes enqueue 'jquery' on the front end (eg.
wp_enqueue_script
). The warning could reference the analysis and perhaps offer a link to an article explaining how to switch to vanilla JavaScript.If this idea seems reasonable, I am happy to work on a PR to add this.