Skip navigation
Currently Being Moderated

Removing comments from all the code?

Feb 5, 2009 10:18 AM

Hello Folks!

What is the best strategy to remove ALL the comments from the .html and .css files before publishing them?
The goal is to end up with a full local website ( with comments and all ), and a cleaned up version ( with all comments removed ) for publishing. What work flow do you use to accomplish this? Is there a way to have dreamweaver do this automatically?

Thanks!
William
 
Replies
  • Currently Being Moderated
    Feb 5, 2009 10:19 AM   in reply to billhdz
    > a cleaned up version ( with all comments removed ) for publishing

    Why bother? You create lots of extra work for yourself with this.

    --
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs, Tutorials & Resources
    ==================


    "billhdz" <webforumsuser@macromedia.com> wrote in message
    news:gmfahk$6gm$1@forums.macromedia.com...
    > Hello Folks!
    >
    > What is the best strategy to remove ALL the comments from the .html and
    > .css
    > files before publishing them?
    > The goal is to end up with a full local website ( with comments and all ),
    > and
    > a cleaned up version ( with all comments removed ) for publishing. What
    > work
    > flow do you use to accomplish this? Is there a way to have dreamweaver do
    > this
    > automatically?
    >
    > Thanks!
    > William
    >
    >

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 5, 2009 10:39 AM   in reply to billhdz
    .oO(billhdz)

    > What is the best strategy to remove ALL the comments from the .html and .css
    >files before publishing them?

    Why? To save 1 or 2 KB? If you're worried about the filesize, have a
    look at HTTP compression instead, that would yield much better results.
    Or is there another reason?

    Micha
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 7, 2009 4:19 PM   in reply to Newsgroup_User
    >>> There has to be a way to automate this. Any ideas?

    Sitewide Find & Replace with Regular Expressions might do what you want but
    I'm not familiar enough with RegEx to assist you I'm afraid.

    However, I think it's far more trouble than it's worth and I'm not aware of
    any web designers who clean out their comments before putting their websites
    online.

    I also find comments in the online code to be a valuable learning tool when
    I'm examining the source code for a website. I get valuable insights into
    the thought process of the web designer and how they structured their code.

    --
    Regards

    John Waller

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 7, 2009 4:26 PM   in reply to Newsgroup_User
    But- if any of the comments are for dreamweaver specific things, like
    templates or similar, would have to do something like copy the files to
    another folder, then strip the comments. so that they are preserved in the
    original site.

    Try this-
    Create another site definition with a new empty local site folder
    Go to original site.
    dw menu->modify->templates->Export without markup
    Set the destination folder as the new site's local folder

    does that clean the files?

    --
    Alan
    Adobe Community Expert, dreamweaver

    http://www.adobe.com/communities/experts/



     
    |
    Mark as:
  • Currently Being Moderated
    Feb 7, 2009 4:49 PM   in reply to Newsgroup_User
    It's not that it's not necessary. It's that it's a useless affectation.
    Spend the time making your code validate instead. Really.

    --
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs, Tutorials & Resources
    ==================


    "billhdz" <webforumsuser@macromedia.com> wrote in message
    news:gml5s0$elh$1@forums.macromedia.com...
    > This is a practice that I like to get into. Clean code online.
    > I know is not necessary, but I like to do it. Is a personal preference.
    > Thanks for the reply.
    >
    > There has to be a way to automate this. Any ideas?
    >

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 1, 2013 10:46 PM   in reply to billhdz

    Options - Not fully automated, but it's a bit closer then some of the answers above. I know this post is old, but I came upon it looking for the same answer and was so frustrated with the many crap answers that I thought I would post something useful for future searchers.

     

    1. Use this dreamweaver query

    <?xml version="1.0"?>

    <dwquery>

      <queryparams matchcase="false" ignorewhitespace="false" useregexp="true" wholeword="false" />

      <find>

        <qtext qname="/\*[\S\s]+?(?=\*/)\*/" qraw="true"></qtext>

      </find>

      <replace action="replaceText" param1="" param2=""/>

    </dwquery>

     

    more details on use at http://foundationphp.com/tools/css_comments.php

     

    2. Use an online minify tool such as http://www.shrinker.ch/

     

    For those who answered with: why bother?  If you don't have an answer then don't post an 'answer'. Your comments are of little value and just hinder others looking for the same answer.

     

    I started with a dreamweaver template and wanted to get rid of the comments because I didn't need them and they were simply taking up space and were annoying to sift through to find the parts I wanted to edit.

     

    I ended up minifying then applying source formatting in dreamweaver to get it cleaned up.

     

    By the way the 'few' kb/s that were saved in this case turned out to be an 80% reduction.  Sure it was only 5kb reduction from 6 to 1kb, however if you had 100,000 people visit your site in a month that is half a gig of data extra and that is just one file.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 2, 2013 9:17 AM   in reply to Thurstanh

    I use code comments to help me and others understand what "thinking" went into the project during development.  Comments are beneficial to me & essential for others who may eventually take over the site. I never strip them out.  YMMV.

     

     

    Nancy O.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 17, 2013 2:45 AM   in reply to Thurstanh

    I agree.  Most of these responses are infuriating, and typical of some know-it-all dev's.  I know not every dev is like this but it's very common, and sadly, especially so on forums.

     

    So...

     

    "Why remove comments?"  ... I have inherited a website project that includes a CSS file with a total of well over 9000 lines.  It is so huge and messy that it's actually slowing DW right down.  I have trimmed about 2,500 of them, and I believe I can trim another 20 - 30% just by removal of the commented out sections, but that's a time-consuming job on an 8000 line file.

     

    So, Thurstanh, thanks very much for the USEFUL reply.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 25, 2013 5:01 PM   in reply to Reverend2009

    Thanks, Thurston, for the one useful reply. I too inherited some very messy code, created by someone who used Word to build websites. I came here to find out how to quickly remove it.

     

    I'm not interested in explaining why I want comments removed, nor am I interested in lessons as to why comments are good to have. I want an answer to my problem so I can get on with my work. I came here to find out of Dreamweaver could help me. And yes, Nancy, my mileage varies very much from yours.

     

    I did find an answer on another site: Under 'Commands' in top menu bar, choose 'Clean up HTML / XHTML'. In dialog box, chose 'Non-Dreamweaver HTML comments'.  Silly me -- I use this function all the time to clean up code and get rid of unwanted tags but never noticed it could get rid of comments as well. 

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 26, 2013 6:27 AM   in reply to DaffodilAzalea

    You can also use Regular Expressions in DW's Find/Replace tool to take comments out:

     

    http://www.adobe.com/devnet/dreamweaver/articles/regular_expressions_p t1.html

     

    Specifically Part 2 talks about removing CSS comments...

     

    http://www.adobe.com/devnet/dreamweaver/articles/regular_expressions_p t2.html

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points