We agreed on a few things in the jQuery issue #1541860: Reduce dependency on jQuery This is the meta tracking the progress. What this aims at is a full review of our JS code.
What we agree on, in order of most important for perfs:
- #1279226: jQuery and Drupal JavaScript libraries and settings are output even when no JS is added to the page
- Look at all our selectors and HTML structure and see how that can be simplified to allow better, faster selectors.
- don't use sizzle-specific selectors if we can avoid it.
- use regular for loops when $(seletor).each() is overkill. Separate the selecting and processing of elements. Typically it means removing the anonymous function when using
.once()
.
The plan is to open an issue for each core file/module and tackle points 2-4 one file at a time.
- #1574484: Selectors clean-up: authorize.js
- #1574696: Selectors clean-up: timezone.js
- #1574512: Selectors clean-up: block
- #1574620: Selectors clean-up: book
- #1751070: Selectors clean-up: states.js
- #1751320: Selectors clean-up: ajax.js
- #1751334: Selectors clean-up: color module
- #1751344: Selectors clean-up: contextual module
- #1751356: Selectors clean-up: field_ui
- #1751388: Selectors clean-up: filter module
- #1751406: Selectors clean-up: node module
- #1751434: Selectors clean-up: user module
- #1751436: Selectors clean-up: bartik/color theme
I've highlighted the ones that would benefit the most. The changes to tabledrag are a bit more drastic than the rest so we might to keep it for the end since it's such a big piece of code.
Feel free to edit and add links to issues. Don't forget to add the "JavaScript Clean-up" tag to every issue you might open for this.
Comments
Comment #0.0
nod_separate some files
Comment #0.1
nod_authorize.js
Comment #1
nod_Since changing some HTML to make things cleaner, adding a few tags.
Comment #1.0
nod_batch.js
Comment #2
neclimduloh man... can we break at least the for loop thing into one patch. That's I and asked for this to be broken down but people(like me) aren't interested in files, we interested in conceptual changes and this makes it really hard to track. Can we open an issue for #2 and #4 in the summary to take a first pass then use the longer list to nail down smaller optimizations or things that where sticking points in the larger issue?
Comment #2.0
neclimduladjust scope
Comment #2.1
nod_block
Comment #2.2
nod_book, statistics
Comment #2.3
nod_book
Comment #3
nod_Comment #3.0
nod_timezone
Comment #3.1
nod_table black-magic
Comment #3.2
nod_tableheader
Comment #4
JacineHey, I hope you don't mind, but in an effort to get a better picture of issues remaining in the HTML5 Initiative, we are removing the "html5" tag from issues that are not directly HTML5-related. Note: Any issues assigned to the "Markup, CSS and JavaScript" components will still be broadcast on the HTML5 Twitter feed so that interested parties are aware and can participate. Thanks! :)
Comment #5
klonos...coming from #1332066: [Meta] Update / Refactor JavaScript as a result of upgrading to jQuery 1.7.
Comment #6
sxnc CreditAttribution: sxnc commentedTried to have a go at this and started with ajax.js: #1751320: Selectors clean-up: ajax.js
Comment #7
nod_The details patch #1168246: Freedom For Fieldsets! Long Live The DETAILS. clean-up a lot of bad selectors, demoting.
Comment #7.0
nod_simplify summary
Comment #8
LewisNyman CreditAttribution: LewisNyman commentedComment #9
Manuel Garcia CreditAttribution: Manuel Garcia commentedAdding #2153177: Convert type selectors to be compatible with jQuery native-API selector as related so people are aware of it.
Comment #10
Manuel Garcia CreditAttribution: Manuel Garcia commentedAdded this issue as parent to all it's children issues I could find.
Comment #11
Manuel Garcia CreditAttribution: Manuel Garcia commentedComment #12
xjmComing here from #1751436: Selectors clean-up: bartik/color theme. So code cleanup for its own sake generally is no longer in scope during the beta; however, it sounds like this has the potential to improve frontend performance. Can we add a beta evaluation that explains the performance improvement a bit more? Thanks!
Comment #13
xjmComment #14
nod_Comment #15
andriyun CreditAttribution: andriyun at Skilld, Drupal Ukraine Community commentedComment #18
andypost