SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    $books++ == true matsko's Avatar
    Join Date
    Sep 2004
    Location
    Toronto
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hide your javascript source

    For those of you who do not know, there is a solution that "hides" and packs the source of your javascript code.

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

    Works well. Infact it reduces the total size of the code causing it to be downloaded faster.

    Mootools uses it as it's as a compression package choice for the mootools build (this build is then used on your website).

    When it all comes down to it, this packing methodology uses eval (big surprise). This can lead to some issues since the actual evaluated solution is not cached by any browser and therefore needs to be executed each time the page is loaded. The underlying code itself looks like a handful, but for mootools (which has a huge amount of source code), my browser seems to execute the evaluation perfectly fine and with no stress.

    So what I am asking here is that when it comes down to the expectations of browser javascript execution, do I really need to worry about overloading a particular user's browser, causing the computer to freeze or at least the browser?
    I can't believe I ate the whole thing

  2. #2
    SitePoint Zealot GiorgosK's Avatar
    Join Date
    Jun 2007
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess you need to worry if you see in your stats that a big part of your audience still uses very old win98 which probably means OLD MACHINES > which in turn means that a little excess of javascript computation can bring the whole computer to a HALT ...

  3. #3
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very good question. I don't use packers for the reason you lined out, but I never did any measuring, so I actually don't know if the tradeoff is worth it. My reasoning is that the machines, which would benefit from a smaller download are probably the same machines, which would choke on unpacking code. I know this isn't necessarily true, but I suspect the two things to go hand in hand.
    Another thing to consider is, that a lot of the time spend downloading is in the establishing of the connection. A file, which takes up double the size, doesn't take double the time to transfer.
    Finally, there are better options for compressing data, than it's possible to implement in javascript. Most clients support gz-compression, which is easily applied by a few configuration options on the server.

  4. #4
    $books++ == true matsko's Avatar
    Join Date
    Sep 2004
    Location
    Toronto
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But you're forgetting the benefit of the hidden JavaScript.
    I can't believe I ate the whole thing

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,215
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by matsko View Post
    But you're forgetting the benefit of the hidden JavaScript.
    some of us can't remember what we might not have known in the first place

    what is the benefit of hidden javascript?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •