Revision: 60424
Updated Code
at November 13, 2012 20:41 by krike
Updated Code
/**
* Function to minify any given string (usefull for javascript)
* @return string
* */
public function minifyJs($code)
{
$code = preg_replace('/((?<!\/)\/\*[\s\S]*?\*\/|(?<!\:)\/\/(.*))/','',$code);
$code = preg_replace("/\n|\r|\t/","", $code);
return $code;
}
Revision: 60423
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 7, 2012 20:10 by krike
Initial Code
/**
* Function to minify any given string (usefull for javascript)
* @return string
* */
public function minifyCode($code)
{
$code = preg_replace('/((?<!\/)\/\*[\s\S]*?\*\/|(?<!\:)\/\/(.*))/','',$code);
$code = preg_replace("/\n|\r|\t/","", $code);
$code = preg_replace("/[ \t]{2,} /"," ", $code);
return $code;
}
Initial URL
https://github.com/krike/WPelements
Initial Description
A usefull function to minify code or string. This is part of the WPelements library class available on Github. Feedback / suggestions / improvements are welcome.
Initial Title
Minify code function
Initial Tags
php, code
Initial Language
PHP