Opened 13 years ago
Closed 4 years ago
#19979 closed enhancement (wontfix)
Load jQuery on the front end for logged-in users
Reported by: | azaozz | Owned by: | morganestes |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Toolbar | Keywords: | needs-patch |
Focuses: | javascript | Cc: |
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);
wheretrue
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 (9)
#4
@
9 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
@
9 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.
Related: #24655