SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,108
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)

    cleaning js - uncommenting, removing white space

    Hi,

    I'm looking for something similiar to CleanCSS if it exists for javascript.
    Does anyone know of a service of function that will strip out all the white space and remove comments from javascript so I can get the filesize down?

    I'm specifically looking for Prototype 1.6 as small as I can get it. I've had a look at the compressed versions and there seems to be considerable performance drawbacks with those methods.


    Thanks,

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,688
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    You could use packer instead of compressor.

    On the other hand if you're wanting to ensure that your code is correct, jslint may be just the ticket.

  3. #3
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    http://www.brainjar.com/js/crunch/demo.html

    Also just go through Prototype and remove all the stuff you don't use.

    pmw57, those two are the same thing. Look at the bottom of the page in the second link you posted.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,688
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    Yes, the packer is version 3 compared to the compressor being version 1.

    That crunchinator from brainjar is a nice one too.

  5. #5
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,108
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    Thanks for the links guys,

    The crunchinator seems to die when.. crunching Prototype 1.6
    Status gets to Removing comments and dies?

    http://www.prototypejs.org/assets/20...6/prototype.js

  6. #6
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Sounds like prototype is a bit big for it!

    Try this:

    http://www.crockford.com/javascript/jsmin

    also put your code through jslint, it can find some useful things to consider:

    http://jslint.com

  7. #7
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,108
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    Thanks, jsmin did just the thing.

    jslint brings up lots of errors for Prototype..

  8. #8
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,688
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    jslint does that. It's about making code consistently better, but it can be finickity at times. It prefers 4 spaces instead of tabs, and spacing between parts of code must follow a certain structure, but it's supposed to help make the code easier to maintain in the future.

  9. #9
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,108
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    Thanks guys


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
  •