Support » Fixing WordPress » Can't compress jquery.js

  • Resolved Olly – OWMC


    Getting very low grades with google page speed. 40-50%.

    it seems there are some files in my wordpress file structure that are escaping my compression attempts. notably /wp-includes/js/jquery/jquery.js?ver=1.7.1

    if i can get that one compressed i’ll only have a few tiny js and css files that arent, and the rest of googles suggestions are low priority. so i figure this should make a pretty big difference to my score.

    gzip compression seems to be enabled with my server as i’ve had some progress.

    i’ve used WordPress Gzip Compression and Scripts Gzip plugins

    also in my .htccess

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress
    # compress the files
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
    # removes some bugs
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    Header append Vary User-Agent
    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain
    AddOutputFilterByType DEFLATE img/svg+xml application/xhtml+xml application/xml
    AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml
    AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
    AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf
    AddOutputFilterByType DEFLATE font/truetype font/opentype
    <IfModule mod_gzip.c>
        mod_gzip_on       Yes
        mod_gzip_dechunk  Yes
        mod_gzip_item_include file      \.(html?|txt|css|js|php|pl)$
        mod_gzip_item_include handler   ^cgi-script$
        mod_gzip_item_include mime      ^text/.*
        mod_gzip_item_include mime      ^application/x-javascript.*
        mod_gzip_item_exclude mime      ^image/.*
        mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

    and this in a file called gzip.php (placed in the site root next to .htaccess)

    ob_start ("ob_gzhandler");
    if( isset($_REQUEST['file']) ){
    $file = $_REQUEST['file'];
    if( goodfile($file) ){
    $ext = end(explode(".", $file));
    case 'css':$contenttype = 'css';break;
    case 'js':$contenttype = 'javascript';break;
    header('Content-type: text/'.$contenttype.'; charset: UTF-8');
    header ("cache-control: must-revalidate");
    $offset = 60 * 60;
    $expire = "expires: " . gmdate ("D, d M Y H:i:s", time() + $offset) . " GMT";
    header ($expire);
    $data = file_get_contents($file);
    $data = compress($data);
    echo $data;
    function goodfile($file){
    if( file_exists($file) ) return true;
    return false;
    function compress($buffer) {
    $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
    $buffer = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
    return $buffer;

Viewing 1 replies (of 1 total)
  • page speed improved as i built the site. unexplainable to me at the time. about 85/100 and haven’t fully optimised it yet. so good.

Viewing 1 replies (of 1 total)
  • The topic ‘Can't compress jquery.js’ is closed to new replies.