MyBB Community Forums

Full Version: UglifyJS Integration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ever check out Google Webmaster Tools? One of the things it has always been telling me to do is to compress JS and CSS files.

https://github.com/mishoo/UglifyJS

Integrating that with MyBB could easily save several kilobytes of downloading and speed things up for everyone.
compressing js has been brought up in the past and you can do it yourself...

But, MyBB doesn't compress default files so it's easier to edit and not all js files are used on all pages.
I'm honestly doubtful that the small compressions made make that much of a difference after you decompress it.
(2011-04-02, 04:48 PM)Scoutie44 Wrote: [ -> ]I'm honestly doubtful that the small compressions made make that much of a difference after you decompress it.

Actually, when Google is telling me this could save upwards of 200kB of downloading, then yes. It makes a big difference.
If MyBB shipped with compressed jscripts we would have tons of threads here from users who can't understand the jscript files as they look a bunch of jibberish to them. Its also a matter of choice, some webmasters prefer to compress, others don't.

If you feel that you need to compress them then by all means go ahead and compress them, the names will remain the same so you won't even have to change the templates.

As far as the css go, since those are stored in the database you can't automatically compress them but with a small code edit you can have a static css file which you can then go ahead and compress. You will however have to make changes in this css manually.
Its not really the compression thats baffling me - its the concatenating. There are a lot of small calls to JS files - if could load prototype and Js from google and concatenate all the rest of the little js.scripts to one file surely that would be faster. Even if not used on every page.
(2011-04-07, 12:54 AM)-AW- Wrote: [ -> ]Actually, when Google is telling me this could save upwards of 200kB of downloading, then yes. It makes a big difference.

Technically, what Google says is right. But it misses out some key words.

Quote:Actually, when Google is telling me this could save upwards of 200kb downloading when visiting for the first time, then yes. It makes a big difference.

Your browser will cache Prototype and Scriptaculous for use when you're browsing the site. It will only 're-download' if you physically refresh the page. So you're technically only downloading it once for the entire time you're visiting the site. We tried using Google's CDN for the larger scripts but it didn't work and there were more problems than it fixed.

As for the smaller javascript calls, those too will be cached by the browser. As long as you have your settings correct, you won't notice any difference.

I am looking into providing compressed versions of Prototype and Scriptaculous (not by default, but with the package), however I'm not so keen in using non-official releases.
(2011-04-07, 01:18 AM)- G33K - Wrote: [ -> ]If MyBB shipped with compressed jscripts we would have tons of threads here from users who can't understand the jscript files as they look a bunch of jibberish to them. Its also a matter of choice, some webmasters prefer to compress, others don't.

If you feel that you need to compress them then by all means go ahead and compress them, the names will remain the same so you won't even have to change the templates.

As far as the css go, since those are stored in the database you can't automatically compress them but with a small code edit you can have a static css file which you can then go ahead and compress. You will however have to make changes in this css manually.

No, don't get me wrong. I'm not arguing against that one (the editable one), but maybe you could have something that could compress a js file while leaving the uncompressed one in that case or something.