Skip to content

Commit 5b5366b

Browse files
authored
Merge pull request #78 from Automattic/break-up-big-groups
break up asset groups of over 150
2 parents c4b3324 + c05b2dd commit 5b5366b

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

concat-utils.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<?php
2-
32
class WPCOM_Concat_Utils {
3+
// Maximum group size, anything over that will be split into multiple groups
4+
protected static int $concat_max = 150;
5+
6+
public static function get_concat_max() {
7+
return self::$concat_max;
8+
}
9+
410
public static function is_internal_url( $test_url, $site_url ) {
511
$test_url_parsed = parse_url( is_string( $test_url ) ? $test_url : '' );
612
$site_url_parsed = parse_url( $site_url );

cssconcat.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ function do_items( $handles = false, $group = false ) {
9898
$stylesheets[ $stylesheet_group_index ] = array();
9999

100100
$stylesheets[ $stylesheet_group_index ][ $media ][ $handle ] = $css_url_parsed['path'];
101+
102+
if ( count( $stylesheets[ $stylesheet_group_index ][ $media ] ) >= WPCOM_Concat_Utils::get_concat_max() ) {
103+
$stylesheet_group_index++;
104+
}
101105
$this->done[] = $handle;
102106
} else {
103107
$stylesheet_group_index++;

jsconcat.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ function do_items( $handles = false, $group = false ) {
129129
$javascripts[$level]['paths'][] = $js_url_parsed['path'];
130130
$javascripts[$level]['handles'][] = $handle;
131131

132+
if ( count( $javascripts[$level]['paths'] ) >= WPCOM_Concat_Utils::get_concat_max() ) {
133+
$level++;
134+
}
135+
132136
} else {
133137
$level++;
134138
$javascripts[$level]['type'] = 'do_item';

ngx-http-concat.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
require_once( __DIR__ . '/concat-utils.php' );
1717

1818
/* Config */
19-
$concat_max_files = 150;
19+
// Maximum group size is set in WPCOM_Concat_Utils::$concat_max, anything over than that will be spit into multiple groups
2020
$concat_unique = true;
2121
$concat_types = array(
2222
'css' => 'text/css',
@@ -114,7 +114,7 @@ function concat_get_path( $uri ) {
114114
concat_http_status_exit( 400 );
115115

116116
// array( '/foo/bar.css', '/foo1/bar/baz.css' )
117-
if ( 0 == count( $args ) || count( $args ) > $concat_max_files )
117+
if ( 0 == count( $args ) || count( $args ) > WPCOM_Concat_Utils::get_concat_max() )
118118
concat_http_status_exit( 400 );
119119

120120
// If we're in a subdirectory context, use that as the root.

0 commit comments

Comments
 (0)