WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#8628 closed enhancement (fixed)

Extend class WP_Scripts to support concatenating, compressing and printing scripts in the HTML head and the footer

Reported by: azaozz Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: Cc:

Description

Many Javascript functions can be loaded in the footer, making the page load faster. Perhaps we can split the current script queue in "head" and "foot" sections and use an extra param when queueing scripts. That way all dependencies and loading order would be preserved.

Alternatively can have two queues and exclude all dependency satisfying scripts that have been loaded in the "head" queue from the "foot" queue.

Attachments (5)

8628.patch (3.8 KB) - added by azaozz 5 years ago.
8628-2.patch (7.8 KB) - added by azaozz 5 years ago.
8628-3.patch (9.2 KB) - added by azaozz 5 years ago.
8628-4.patch (40.8 KB) - added by azaozz 5 years ago.
8628-5.patch (40.6 KB) - added by azaozz 5 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 mdawaffe5 years ago

We should have only one queue. By that I mean only one WP_Scripts object. An extra parameter ought to work fine

azaozz5 years ago

azaozz5 years ago

azaozz5 years ago

comment:2 djr5 years ago

  • Cc djr added

azaozz5 years ago

azaozz5 years ago

comment:3 azaozz5 years ago

  • Summary changed from Extend class WP_Scripts to print scripts in both the HTML head and the footer to Extend class WP_Scripts to support concatenating, compressing and printing scripts in the HTML head and the footer

comment:4 azaozz5 years ago

(In [10357]) Split the script queue in head and footer part, concatenate and compress the default js and css, first run, see #8628

comment:6 azaozz5 years ago

(In [10442]) Improvements to the script loader: allows plugins to queue scripts for the front end head and footer, adds hooks for server side caching of compressed scripts, adds support for ENFORCE_GZIP constant (deflate is used by default since it's faster), see #8628, fixes #8884

comment:7 azaozz5 years ago

(In [10476]) Detect when the server compresses output, see #8628

comment:8 Viper007Bond5 years ago

Farbtastic completely breaks this script loader.

Steps To Reproduce:

  1. Download and activate my Video Quicktags plugin: http://wordpress.org/extend/plugins/vipers-video-quicktags/
  2. Visit Settings -> Video Quicktags in Firefox 3. Note page is there for a moment and then disappears. Disabling JS makes it appear fine.
  3. Comment out wp_enqueue_script( 'farbtastic', ... line in plugin. Page works as expected.

Checking JS error console shows these errors:

Error: S.documentElement is null
Source File: http://localhost/wordpress-dev/wp-admin/load-scripts.php?c=1&load=jquery,utils&ver=960edfac60367b8ae4d41cab123ae351
Line: 19
Error: document.body is null
Source File: http://localhost/wordpress-dev/wp-admin/load-scripts.php?c=1&load=jquery,utils&ver=960edfac60367b8ae4d41cab123ae351
Line: 19

comment:9 azaozz5 years ago

(In [10496]) Load farbtastic.js has to be loaded in the head, see #8628

comment:10 Denis-de-Bernardy5 years ago

also #9242 (the same for styles, and plugin scripts)

comment:11 janeforshort5 years ago

  • Keywords has-patch added

comment:12 ryan5 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.