Ticket #9242 (closed enhancement: duplicate)

Opened 3 years ago

Last modified 3 years ago

Auto-magically reduce the number of plugin/theme script and css files

Reported by: Denis-de-Bernardy Owned by: anonymous
Priority: normal Milestone:
Component: Optimization Version: 2.7
Severity: normal Keywords: needs-patch
Cc:

Description

I'm running into a performance problem on a site that I've found to be mostly due to the number of assets used on it. As in, the number of js and css files that get included.

Could it be possible to add one or more hooks somewhere in WP_Dependencies that would let a plugin author catch every static js or css file, so as to bundle each and everyone of them in a single js or css file?

In other words, after calling do_action(wp_print_script), we'd do something like:

foreach depends
  if extension is js
  then
    add to bundles
    delete from queue

bundle_id = md5(serialize(bundles))

if !file_exists(wp-content/bundle_id.js)
then
  foreach bundles
    str .= file_get_contents(bundle)
  file_put_contents(wp-content/bundle_id.js, str)

enqueue wp-content/bundle_id.js

and continue as we'd normally do
(and the same thing for css files)

Better yet, could the above behavior be built into the WP core?

Change History

  • Keywords dev-feedback added
  • Keywords needs-patch added; dev-feedback removed
  • Summary changed from Auto-magically reduce the number of assets to Auto-magically reduce the number of plugin/theme script and css files
  • Milestone changed from 2.8 to 2.9

This was apparently done with WP in 2.8. It now needs to be done for plugins and themes now.

  • Status changed from new to closed
  • Resolution set to duplicate
  • Milestone 2.9 deleted

dup of #8628

Note: See TracTickets for help on using tickets.