Skip to content

Commit 0839d32

Browse files
Script loader: remove (PHP based) compression from load-styles.php and load-scripts.php. WIth the amount of scripts and stylesheets grown a lot over the years, it has become pretty slow and consumes a lot of server resources. Also, most servers are set to compress PHP output anyway.
Props LucasRolff, azaozz. Merges [43580] to the 4.9 branch. Fixes #44815. See #43308. git-svn-id: https://develop.svn.wordpress.org/branches/4.9@43618 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 29e5fe2 commit 0839d32

File tree

2 files changed

+0
-26
lines changed

2 files changed

+0
-26
lines changed

src/wp-admin/load-scripts.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
require( ABSPATH . WPINC . '/script-loader.php' );
2929
require( ABSPATH . WPINC . '/version.php' );
3030

31-
$compress = ( isset($_GET['c']) && $_GET['c'] );
32-
$force_gzip = ( $compress && 'gzip' == $_GET['c'] );
3331
$expires_offset = 31536000; // 1 year
3432
$out = '';
3533

@@ -58,16 +56,5 @@
5856
header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
5957
header("Cache-Control: public, max-age=$expires_offset");
6058

61-
if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
62-
header('Vary: Accept-Encoding'); // Handle proxies
63-
if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
64-
header('Content-Encoding: deflate');
65-
$out = gzdeflate( $out, 3 );
66-
} elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
67-
header('Content-Encoding: gzip');
68-
$out = gzencode( $out, 3 );
69-
}
70-
}
71-
7259
echo $out;
7360
exit;

src/wp-admin/load-styles.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
if ( empty($load) )
2929
exit;
3030

31-
$compress = ( isset($_GET['c']) && $_GET['c'] );
32-
$force_gzip = ( $compress && 'gzip' == $_GET['c'] );
3331
$rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] );
3432
$expires_offset = 31536000; // 1 year
3533
$out = '';
@@ -80,16 +78,5 @@
8078
header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
8179
header("Cache-Control: public, max-age=$expires_offset");
8280

83-
if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
84-
header('Vary: Accept-Encoding'); // Handle proxies
85-
if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
86-
header('Content-Encoding: deflate');
87-
$out = gzdeflate( $out, 3 );
88-
} elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
89-
header('Content-Encoding: gzip');
90-
$out = gzencode( $out, 3 );
91-
}
92-
}
93-
9481
echo $out;
9582
exit;

0 commit comments

Comments
 (0)