We've had this problem as well and are open to learning the best practices.
The eZ Flow timeline handles this on the JavaScript side. There's a lot of postprocessing in timeline.js but here is an example where they strip out HTML comments:
// Remove any html comments that might exists in the js. It seems to upset firefox.
script = script.gsub( "<!--", "" );
script = script.gsub( "//-->", "" );
script = script.gsub( "-->", "" );