YUI remove javascript comments
Asked Answered
C

1

19

I need to remove comments (the "// This is a comment" like comments) from some Javascript code, I'm using YUI compressor, there is an option to do that?

Thanks


Thanks for the response, I'm trying to merge several scripts and after compress with YUI; I've found if I compress and then merge the scripts it works, but if I merge and then compress, something goes wrong and I got a broken script

Carbazole answered 23/8, 2010 at 13:25 Comment(3)
I merge then compress in my project and it works just fine. Do your scripts rely on lots of global variables and global functions? Maybe that's creating a problem for the compressor. How is it "broken"?Ambages
the recommended way is to MINIFY each file first, then combine them secondly. Not the other way around. Is there any reason why you can't Minify then Combine?Southerland
@Southerland Could you explain why it's recommended to minify before combining? I have an active question on this topicEmptor
A
26

YUI Compressor removes comments by default. You have to use a special comment format to keep comments.

/*! This comment will not be removed, so it's a good place to put a copyright */

// this comment will be removed

/* this one too */
Ambages answered 23/8, 2010 at 14:3 Comment(1)
it is removing only // comments all /* comments are not removed #20832097Erde

© 2022 - 2024 — McMap. All rights reserved.