Please upgrade here. These earlier versions are no longer being updated and have security issues.

Javascript Compression in Vanilla 2.0.18.10

phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP
edited March 2014 in Vanilla 2.0 - 2.8

Hi all,

Vanilla loads quite some Javascripts and i wanted to ask you what would be the smartest thing to reduce the number of files loaded and compress the .js files of the Core and the Plugins correctly.

  • X I tried to compress sole files separatly to reduce them in size. It always broke the related function of the forum.
  • X I tried to install the plugins in the repository available, it also broke the functions.
  • ! Besides of that i run Google DFP as AdServer so not "every" JS on the page should be compressed (or the banners will break).
  • ? How is it possible to move the JS files loading on DOM below the fold. Now they all are getting loaded in the header, what is not very recommendable.

    <script src="/js/library/jquery.js?v=2.0.18.8" type="text/javascript"></script> <script src="/js/library/jquery.livequery.js?v=2.0.18.8" type="text/javascript"></script> <script src="/js/library/jquery.form.js?v=2.0.18.8" type="text/javascript"></script> <script src="/js/library/jquery.popup.js?v=2.0.18.8" type="text/javascript"></script> <script src="/js/library/jquery.gardenhandleajaxform.js?v=2.0.18.8" type="text/javascript"></script> <script src="/js/global.js?v=2.0.18.8" type="text/javascript"></script> <script src="/applications/vanilla/js/bookmark.js?v=2.0.18.8" type="text/javascript"></script> <script src="/applications/vanilla/js/discussions.js?v=2.0.18.8" type="text/javascript"></script> <script src="/applications/vanilla/js/options.js?v=2.0.18.8" type="text/javascript"></script> <script src="/js/library/jquery.gardenmorepager.js?v=2.0.18.8" type="text/javascript"></script> <script src="/plugins/WhosOnline/whosonline.js?v=1.3" type="text/javascript"></script>

I decided to make a new thread about this, because related discussions are quiet old, related plugins in the repository seem to be not working properly and new methods and tools for JS compression appear several times a year. Also i think not many Vanilla board makers "compress" their forums with aim, but it could help to let more and more Vanilla forums float to the top of the SERPs. Surely because of some concentration on my forums page speed and also because of the growing community my forum made it to the top discussion groups on a popular topic in my country.

Does anyone have recommendations for me?
Easy to integrate. ;)

Thanx

  • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
  • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla

Comments

  • x00x00 MVP
    edited March 2014

    Don't do it. There is little point. These script will be cached anyway, it serves no purpose, becuase any gain is negligible and pretty irrelevant if cached.

    JavaScript obfuscation is a flawed process. It should absolutely not be used as part of general framework solution ever, full stop. Only ever as a build process of some project.

    Instead you might try consolidate.
    http://vanillaforums.org/addon/consolidate-plugin

    Also you can use CDN.

    grep is your friend.

    peregrineShadowdare
  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff
    edited March 2014

    Combining and compressing assets has huge performance gains (clicky!) so I can definitely see why you'd want to do so. However—like @x00 has already mentioned—Javascript obfuscation is indeed a flawed process in most cases. I have yet to find a stand-alone PHP library that actually does a perfect job at it. Uglify.js is what I use myself (Node is my go-to environment when I'm not at work) and they have a pretty neat API service that a plugin could potentially utilize.

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

    peregrineShadowdare
  • x00x00 MVP
    edited March 2014

    I would take with a grain of salt one set of idealized tests.

    You have to be wary of the domino effect. for one, and any gain may be matched by a good CDN.

    There is difference between JavaScript compression and obfuscation, but both can break the code.

    Some JavaScript compression is syntactic and re-factors the code (e.g js packer) and not just code style that may break. This may have impact on the performance of the code itself, it may also run counter to the intended purpose.

    it you are writing in per-processed/compiling language such as coffee script, then you could streamline that so eventually you produce optimised JavaScript for transport.

    However as it was never developed to be used this way. It is difficult to get right. if they design the language from scratch, they could make a language more conducive to this sort of thing, with less pitfall in reducing it.

    Most content transported is compressed anyway just is a general not destructive way.

    You can even reduce the footprint of transporting html by html compression, this can also break things too. But not as bad as JavaScript.

    grep is your friend.

    businessdad
Sign In or Register to comment.