Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#23875 closed defect (bug) (fixed)

Twenty Thirteen: improve jQuery code: remove deprecated functions, namespace events, and more

Reported by: obenland's profile obenland Owned by:
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.6
Component: Bundled Theme Keywords: has-patch
Focuses: Cc:

Description (last modified by lancewillett)

  1. The syntax $(document).on("ready", handler) is deprecated as of jQuery 1.8.

It behaves similarly to the ready method but if the ready event has already fired and you try to .on("ready") the bound handler will not be executed. See:

  1. We should namespace events:
  1. The scroll event should be throttled for performance.

Attachments (5)

23875.diff (420 bytes) - added by obenland 11 years ago.
23875.1.diff (3.9 KB) - added by lancewillett 10 years ago.
23875.2.diff (1.8 KB) - added by obenland 10 years ago.
23875.3.diff (2.7 KB) - added by lancewillett 10 years ago.
23875.4.diff (1.8 KB) - added by lancewillett 10 years ago.

Download all attachments as: .zip

Change History (16)

11 years ago

#1 @lancewillett
11 years ago

  • Priority changed from normal to low

I'm going to leave this 'til after beta, we can do some other general refactoring here.

#2 @nacin
10 years ago

In 23891:

Don't use jQuery.on('ready'). props obenland. see #23875.

#3 @lancewillett
10 years ago

  • Description modified (diff)
  • Keywords needs-refresh added
  • Priority changed from low to normal
  • Summary changed from Twenty Thirteen: Replace deprecated jQuery code to Twenty Thirteen: improve jQuery code: remove deprecated functions, namespace events, and more

#4 @lancewillett
10 years ago

  • Keywords needs-testing added; needs-refresh removed

.1 patch does the following:

  • Moves away from namespaced function names, just make them same scope as other variables
  • Add event namespacing
  • Add debounce function and use it to throttle scroll events
  • Code comment improvements

#5 @lancewillett
10 years ago

In 24004:

Twenty Thirteen: improvements to functions.js to add namespacing to events and simplify repeatable functions. See #23875.

10 years ago

#6 @lancewillett
10 years ago

.3 builds on .2 from obenland to introduce a short delay so we don't trigger an avalanche of function calls with the scroll handler.

Thoughts on the UX? The navbar will hide and show with a tiny delay instead of being instant.

#7 @lancewillett
10 years ago

In 24005:

Twenty Thirteen: further performance for functions.js scroll event callback, props obenland. See #23875.

#8 @lancewillett
10 years ago

Further improvements to the scroll event now pending a decision: we discussed removing the fixed navbar completely today, in IRC #wordpress-dev, see log.

#9 @lancewillett
10 years ago

@mfields brought to my attention a possible XSS vulnerability at

Where we don't check that the hash input is a valid element in the DOM.

See .4 diff for his suggested patch.

This approach is closer to the original code at and also closes a possible XSS vulnerability in jQuery Migrate, see

Last edited 10 years ago by lancewillett (previous) (diff)

#10 @lancewillett
10 years ago

In 24070:

Twenty Thirteen: update JavaScript-based accessibility function hooked to hashchange event to verify user input correctly. Props mfields for the original patch.

Also add textarea to list of elements. See #23875.

#11 @lancewillett
10 years ago

  • Keywords needs-testing removed
  • Resolution set to fixed
  • Status changed from new to closed

Closing now that #24184 negates the need to throttle the scroll event (which will be removed).

Note: See TracTickets for help on using tickets.