I am building a PHP script to minimize CSS / Javascript , which (obviously) includes getting rid of comments from the file. Any ideas how to do this? (Preferably, I need to get rid of the comments /**/ and // )
/**/
//
This wheel was invented - http://code.google.com/p/minify/ .
Template for deleting comments in JS
$pattern = '/((?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:\/\/.*))/';
CSS Removal Template
$pattern = '!/\*[^*]*\*+([^/][^*]*\*+)*/!'; $str = preg_replace($pattern, '', $str);
I hope the above should help someone ..
REFF: http://castlesblog.com/2010/august/14/php-javascript-css-minification
Take a look at minify , "heavy regex- based white space removal, unnecessary comments and tokens."
Source: https://habr.com/ru/post/1333049/More articles:Getting wiki from TinyMCE / CKEditor (for Trac plugin) - javascriptjava: ClassCastException - [Ljava.lang.Long; cannot be added to java.lang.Long - javahttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1333046/ckeditor-3x-dynamically-add-ui-elements-to-plugin-dialog&usg=ALkJrhiUPORZfOMbyNav6X7HC34zVEsJBQHow can I avoid the expiration of the page? - htmlSession cookies working under a subdomain - phpHow to unzip client page on HTML pages - jqueryC: theory on how to extract files from an archive file - cExtract sketch and icon from file in C # - c #The physical significance of the rotation of the filter matrix in the filter2 function - matrixWebsphere MQ Theme and SSL - securityAll Articles