WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#9242 closed enhancement (duplicate)

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

Reported by: Denis-de-Bernardy Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.7
Component: Optimization Keywords: needs-patch
Focuses: 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 (3)

comment:1 Denis-de-Bernardy5 years ago

  • Keywords dev-feedback added

comment:2 Denis-de-Bernardy5 years ago

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

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

comment:3 Denis-de-Bernardy5 years ago

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

dup of #8628

Note: See TracTickets for help on using tickets.