1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Xenforo.js is not compressed?

Discussion in 'Server Configuration and Hosting' started by Renegade, Mar 29, 2013.

  1. Renegade

    Renegade Well-Known Member

    Page speed and other tools show that the xenforo.js file is not compressed. I have mod_deflate enabled and I think all pages and files are compressed except this.

    Is there something I need to do specifically for this file?
     
  2. cclaerhout

    cclaerhout Well-Known Member

    The file is minified in the "xenforo" js folder, but not in its subdirectory "full" (which is logical).
     
  3. Teapot

    Teapot Well-Known Member

    Because of the way the XenForo JS is compressed, automated JS minifiers (and YSlow/Google Page Speed) report that it can be compressed further. Actually minifying the files further with default settings breaks the JS, though - I haven't yet found a way around that.
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    Compare it to the one in js/xenforo/full

    Now tell me it's not compressed :)

    Even if it can be compressed further, any further compression would be negligible.
     
  5. digitalpoint

    digitalpoint Well-Known Member

    No it doesn't... I minified the default xenforo.js file and it cut about 4k out of the "already minified" version that comes with XenForo and doesn't break anything.

    Try it yourself: https://tools.digitalpoint.com/javascript-compressor

     
    Breixo and Brandon Sheley like this.
  6. Renegade

    Renegade Well-Known Member

    Code:
    FAILED - (127.7 KB, compressed = 40.1 KB - savings of 87.6 KB) - http://www.techenclave.com/community/js/xenforo/xenforo.js?_v=3067a8be
    Why is it that this warning doesn't come up when checking xenforo.com loading time.
    http://www.webpagetest.org/result/130401_RS_A21/2/performance_optimization/#compress_text

    But comes up when checking my forum
    http://www.webpagetest.org/result/130401_7E_9X1/1/performance_optimization/#compress_text

    Also how can I check the reason for First Byte time being so high for my forum as compared to that of XF.
     
  7. Renegade

    Renegade Well-Known Member

    Anyone has a clue why the following is appended at the end of the xenforo.js file? I think this is why it is not getting gzipped by the server.

    ?_v=3067a8be
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    At a guess I would say that's a unique string for cache purposes.
     
  9. Renegade

    Renegade Well-Known Member

    I don't have cache enabled through the config file, nor do I have the minify enabled from acp. This particular JS file does not get flagged when do a speed test for xenforo. I do get it for cliptheapex with the exact same string. So doesn't look like unique to me.
     
  10. Brogan

    Brogan XenForo Moderator Staff Member

    I mean browser caching and unique for the build, not for each installation.
     
  11. shawn

    shawn Well-Known Member

    This. You need the version qualifier so that a visitor's browser knows when to request an updated copy of the file.
     
  12. Renegade

    Renegade Well-Known Member

    Why is it required only for this file then? There are so many other files without this.
     
  13. shawn

    shawn Well-Known Member

    Any JS or CSS file should have a unique version identifier appended to it for cache compatibility. If you look at the source for an XF page, you'll find them on all JS and CSS files. CSS files use the 'd' variable (date in unixtime), but it's the same thing.
     
  14. Brogan

    Brogan XenForo Moderator Staff Member

    As do avatars: 2842.jpg?1301945502
     
    Mr.Rick likes this.
  15. Hardcore

    Hardcore Active Member

    I was having the same exact issue with Apache, but eventually found a solution.

    I'm assuming you already have this in your config file:
    Code:
    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE application/x-httpd-php
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    </IfModule>
    Add this before the end of the </IfModule>:
    Code:
    <LocationMatch "\.(css|js|x?html?|php)$">
      SetOutputFilter DEFLATE
    </LocationMatch>
    Restart and check again.

    This worked for me, and others online who were having the same issue. Good luck.
     
    Renegade likes this.
  16. Renegade

    Renegade Well-Known Member

    Now I am a bit confused. I cannot find mod_deflate or mod_expires in any of the httpd.conf file or the .htaccess file on my server. But they both are enabled. :confused:
    Where am I not looking?
     
  17. Hardcore

    Hardcore Active Member

    Simply loading the mod_deflate module doesn't activate it, but rather gives you access to using it.

    For example, you'd need to add that code within one of your <VirtualHost> containers for whatever server XF is running on; that'll active mod_deflate for that specific server, using the above rules.
     
  18. Renegade

    Renegade Well-Known Member

    Done thanks. :)
     

Share This Page