WordPress.org

Make WordPress Core

Opened 8 years ago

Last modified 3 years ago

#19979 assigned enhancement

Load jQuery on the front end for logged-in users

Reported by: azaozz Owned by: morganestes
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Toolbar Keywords: needs-patch
Focuses: javascript Cc:
PR Number:

Description

This will let us simplify the toolbar JS and improve user experience: hoverIntent, additions by plugins that require jQuery, etc.

jQuery can be loaded in two different ways:

  • Directly, by enqueueing it with script_loader and then adding wpjq = jQuery.noConflict(true); where true means other version of jQuery will be left with the globals.
  • By outputting some JS at the very end of 'wp_footer'. This JS would be able to check whether jQuery is already loaded and if not, load it by appending a <script src="..."> tag to the head (note that this method would load jQuery asynchronously).

Previous discussion in some of the comments on #18758.

Change History (7)

#2 @chriscct7
4 years ago

  • Keywords needs-patch added

#3 @johnbillion
4 years ago

#24655 was marked as a duplicate.

#4 @morganestes
4 years ago

  • Focuses javascript added
  • Milestone changed from Future Release to 4.5
  • Owner set to morganestes
  • Status changed from new to assigned

I think that it's time to revisit this and see how well it fits in with #32678 (I think it does). Getting it in early would certainly help with some other enhancements coming soon.

I'm in favor of loading core's version of jQuery using noConflict() without resorting to the extra inline script for fallback checks, but we should check to be sure the toolbar is displayed before enqueuing it (see #33165). We also need to allow for the fact that a theme or plugin may dequeue core's jQuery on the front end, and what that means for any JS we build that relies on core's version.

#5 @peterwilsoncc
4 years ago

As part of the scope for this, I'd like to investigate the reverse. Can the admin bar's JavaScript be simplified by removing the jQuery portion.

As jquery is two files, jquery-core and jquery-migrate, the end result would be three extra HTTP requests for the admin JS. It's a lot of code for the admin bar.

#6 @ocean90
4 years ago

  • Milestone changed from 4.5 to Future Release

#7 @SergeyBiryukov
3 years ago

#39784 was marked as a duplicate.

Note: See TracTickets for help on using tickets.