Results 1 to 9 of 9

Thread: Pack JS Files ?

  1. #1
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Question Pack JS Files ?

    Hi.

    Is there a way or a tool to pack js files in order to speed up loading times?

    I know that it is possible but I'm looking for an easy way to achive it.

    Please give me some advise,
    Cheng

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    You mean like a minifier? This is a good one: http://fmarcia.info/jsmin/test.html

    Good luck!
    Eddy Proca
    I love Dropbox. Get it through my girlfriend's referral link (I reached my limit) and both you and her get 500 MB extra! Thanks and you're welcome!

  3. #3
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    .......thanks a lot, this is what I was looking for.

    I found one myself as well by now which is quiet nice:

    http://dean.edwards.name/packer/

    Does the packing really speed up the loading process or does it just compress the file size...?...
    Cheng

  4. #4
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    Those two things go hand-in-hand. The smaller the file size, the faster it will load.
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@ /\/\@|{
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That's not necessarily true. A lot of packers use eval(), which will actually considerably slow the loading process overall, since it's still loading the full-sized script, but with an extra compiler instance started up first, plus the overhead of unpacking.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franais | entiendo espaol | ti t hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    Yes you are right about that. On a small script (~1000 characters) it took four times longer packed, then unpacked. But the code does get to the browser faster and is smaller, therefore compromise is needed. In my opinion most scripts should only have whitespace stripped and variables shrunk.
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@ /\/\@|{
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  7. #7
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    .......what I'm using is a large js file which is 48 kb and packed it is only 22 kb.

    Since I'm on a dialup connection at the moment using my mobile to connect I'm very concerned about speed and I noticed that with the packed js file the site is defnitely loading faster.......
    Cheng

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    There's loading speed, and there's transfer speed. A basic packer, just renaming identifiers and stripping whitespace and comments, can increase transfer speed (by making the file smaller) and also marginally increase loading speed (since there's less to parse). However, eval()-based packers will increase transfer speed possibly a little more (if written with care), but at the cost of vastly reducing loading speed. Both options, of course, leave the final script pretty much unreadable.

    There is a better solution: all modern browsers and servers support on-the-fly gzip compression. Using this will significantly decrease the amount of network traffic, at the cost of a little more resource usage on either end. Best of all, it's transparent: you can just enable it and forget about it. Everything will happen automatically, and your users will see a fully-featured, unobfuscated, readable script.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franais | entiendo espaol | ti t hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Jan 2006
    Posts
    234
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    .......for the beginning I'm using a packer like mentioned above because I couldn't figure out as yet how to use the on-the-fly gzip compression and the packers are easy to use.......
    Cheng

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •