WordPress.org

Make WordPress Core

Opened 14 months ago

Last modified 9 months ago

#32793 new enhancement

Combine jQuery and jQuery migrate to reduce HTTP requests

Reported by: peterwilsoncc Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.6
Component: External Libraries Keywords: needs-refresh
Focuses: javascript, performance Cc:

Description

Combining the jQuery and jQuery migrate scripts will improve performance by reducing HTTP requests. As jQuery scripts are loaded in the header, this will reduce the period of render blocking.

In the attached patch

  • the files load separately when SCRIPT_DEBUG is enabled
  • jquery-core and jquery-migrate effectively become aliases of jquery
  • aliases are queued to footer to allow theme/plugin devs to move jQuery to footer if they wish

Cons/risks

  • plugins/themes replacing jquery with a CDN version could remove migrate
  • drama and pushback from devs who keep their code free of deprecated jQuery functions

Attachments (2)

32793.1.diff (2.8 KB) - added by peterwilsoncc 14 months ago.
32793.2.diff (2.8 KB) - added by peterwilsoncc 14 months ago.

Download all attachments as: .zip

Change History (8)

#1 follow-up: @Otto42
14 months ago

It has been pointed out that jQuery-migrate can introduce vulnerabilities fixed in past versions of jQuery.

http://wphighed.org/2014/10/potential-cross-site-scripting-vulnerability-in-jquery-scripts/

Should we instead look at a way to reduce the need for jQuery-migrate and get everybody to use the most recent versions, without old dependencies?

#2 in reply to: ↑ 1 @peterwilsoncc
14 months ago

  • Keywords has-patch added

Replying to Otto42:

Should we instead look at a way to reduce the need for jQuery-migrate and get everybody to use the most recent versions, without old dependencies?

#22975 and #25371 (and I'm sure others) dealt with removing deprecated functions from core. Including a test for deprecated functions in grunt would be a useful addition to the core build process.

It would be nice to encourage plugin and theme developers to use jquery-core but it does run the risk of abandoned plugins blowing up sites' JavaScript. But yes, it would be useful.

#3 @netweb
14 months ago

Related: #32358

#4 @peterwilsoncc
14 months ago

  • Keywords needs-refresh added

Refresh reqd following #32794 [32978]

#5 @peterwilsoncc
14 months ago

  • Keywords needs-refresh removed

32793.2.diff contains the refresh for jQuery 1.11.3

#6 @peterwilsoncc
9 months ago

  • Keywords needs-refresh added; has-patch removed
Note: See TracTickets for help on using tickets.