Opened 4 years ago

Closed 4 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: anonymous
Priority: normal Milestone: 2.8
Component: General Version:
Severity: normal Keywords: has-patch
Cc: djr

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 4 years ago.
8628-2.patch (7.8 KB) - added by azaozz 4 years ago.
8628-3.patch (9.2 KB) - added by azaozz 4 years ago.
8628-4.patch (40.8 KB) - added by azaozz 4 years ago.
8628-5.patch (40.6 KB) - added by azaozz 4 years ago.

Download all attachments as: .zip

Change History (17)

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

azaozz4 years ago

azaozz4 years ago

azaozz4 years ago

comment:2   djr4 years ago

  • Cc djr added

azaozz4 years ago

azaozz4 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

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

(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

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

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

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

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

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