Minify given JavaScript source and cache the result if applicable

@param  string $src JavaScript source
@return string      Minified source
971865
public function get($src)
	{
		try
		{
			return (isset($this->cacheDir)) ? $this->getFromCache($src) : $this->minify($src);
		}
		catch (Exception $e)
		{
			if (!$this->keepGoing)
			{
				throw $e;
			}
		}

		return $src;
	}
1186393
private function compressSource($src, $compress)
    {
        $content = $assetContent = '';
        $assetContent = @file_get_contents($this->container->get('root').DS.$src);
        $content .= ($compress) ?
            compress($assetContent).PHP_EOL :
            $assetContent.PHP_EOL;

        return $content;
    }
170774
protected function attr($src = null, array $attr = array())
    {
        if (null !== $src) {
            $attr['src'] = $src;
        }
        $attr['type'] = 'text/javascript';
        return $this->escaper->attr($attr);
    }
1316742
public function resolveScriptVersion($filename, $minified = false)
    {
        list($name, $extension) = str_split($filename, strrpos($filename, '.') + 1);
        return !$minified ? $name . $extension : $name . 'min.' . $extension;
    }
488038
public static function minify($str)
    {
        $matchesCode = $matchesPre  = $matches     = [];

        preg_match_all('/<code.*?>(.*?)<\/code>/mis', $str, $matchesCode);
        preg_match_all('/<pre.*?>(.*?)<\/pre>/mis', $str, $matchesPre);
        $matches = array_merge($matchesCode[1], $matchesPre[1]);
        foreach ($matches as $match) {
            $str = str_replace($match, '$'.md5($match), $str);
        }
        $str = preg_replace(['/<!--(.*)-->/Uis', "/[[:blank:]]+/"], ['', ' '],
            str_replace(["\n", "\r", "\t"], '', $str));
        foreach ($matches as $match) {
            $str = str_replace('$'.md5($match), $match, $str);
        }
        return $str;
    }
919720
private function build_src( $src ) {
		if ( ! preg_match( '/^(https?:)?\/\//u', $src ) ) {
			// O.K. This is a library in WPametu!
			$src = trailingslashit( $this->get_root_uri() ) . ltrim( $src, '/' );
		}

		return $src;
	}
431463
public function minify($json){
			$tokenizer = "/\"|(\/\*)|(\*\/)|(\/\/)|\n|\r/";
			$in_string = false;
			$in_multiline_comment = false;
			$in_singleline_comment = false;
			$tmp; $tmp2; $new_str = array(); $ns = 0; $from = 0; $lc; $rc; $lastIndex = 0;
			while (preg_match($tokenizer,$json,$tmp,PREG_OFFSET_CAPTURE,$lastIndex)){
				$tmp = $tmp[0];
				$lastIndex = $tmp[1] + strlen($tmp[0]);
				$lc = substr($json,0,$lastIndex - strlen($tmp[0]));
				$rc = substr($json,$lastIndex);
				if (!$in_multiline_comment && !$in_singleline_comment){
					$tmp2 = substr($lc,$from);
					if (!$in_string){
						$tmp2 = preg_replace("/(\n|\r|\s)*/","",$tmp2);
					}
					$new_str[] = $tmp2;
				}
				$from = $lastIndex;
				if ($tmp[0] == "\"" && !$in_multiline_comment && !$in_singleline_comment){
					preg_match("/(\\\\)*$/",$lc,$tmp2);
					if (!$in_string || !$tmp2 || (strlen($tmp2[0]) % 2) == 0){ // start of string with ", or unescaped " character found to end string
						$in_string = !$in_string;
					}
					$from--; // include " character in next catch
					$rc = substr($json,$from);
				} else if ($tmp[0] == "/*" && !$in_string && !$in_multiline_comment && !$in_singleline_comment){
					$in_multiline_comment = true;
				} else if ($tmp[0] == "*/" && !$in_string && $in_multiline_comment && !$in_singleline_comment){
					$in_multiline_comment = false;
				} else if ($tmp[0] == "//" && !$in_string && !$in_multiline_comment && !$in_singleline_comment){
					$in_singleline_comment = true;
				} else if (($tmp[0] == "\n" || $tmp[0] == "\r") && !$in_string && !$in_multiline_comment && $in_singleline_comment){
					$in_singleline_comment = false;
				} else if (!$in_multiline_comment && !$in_singleline_comment && !(preg_match("/\n|\r|\s/",$tmp[0]))){
					$new_str[] = $tmp[0];
				}
			}
			$new_str[] = $rc;
			return implode("",$new_str);
		}
718440
protected function _minify($css)
    {
        return ($this->_minifier instanceof \Tollwerk\Squeezr\Css\Minifier) ? $this->_minifier->minify($css) : $css;
    }
841735
private function open_php( &$src ){
		if( ! $this->inphp ){
			$this->inphp = true;
			
			// this may result in back to back tags, which we can avoid with a bit of string manipulation.
			$makenice = $this->opt(COMPILER_OPTION_NICE_TAGS);
			
			if( $makenice && substr( $src, -2 ) === '?>' ){
				// trim trailing close tag, so no need to open one
				$src = substr_replace( $src, '', -2 );
			}
			else {
				$ws = $this->opt(COMPILER_OPTION_WHITESPACE) ? "\n" : ' ';
				$src .= '<?php'.$ws;
			}
		}
		return $src;	
	}
414070
protected function minify($code)
    {
        $code = (string) parent::minify($code);

        $code = preg_replace('/( )?=( )?/', '=', $code);

        $code = preg_replace('/( )?\(( )?/', '(', $code);

        return preg_replace('/( )?var ( )?/', '', $code);
    }
331018
public static function minifyJavaScript($script, &$error = '') {
		require_once(PATH_typo3 . 'contrib/jsmin/jsmin.php');
		try {
			$error = '';
			$script = trim(JSMin::minify(str_replace(CR, '', $script)));
		}
		catch (JSMinException $e) {
			$error = 'Error while minifying JavaScript: ' . $e->getMessage();
			self::devLog($error, 't3lib_div', 2,
				array('JavaScript' => $script, 'Stack trace' => $e->getTrace()));
		}
		return $script;
	}
1068821
public function resize_crop($src) {
        $image_details = $this->build_image($src);

        if ($image_details !== false) {
            list($src, $src_width, $src_height) = $image_details;

            if (($src_width / $src_height) > ($this->width / $this->height)) {
                $src_w = $this->get_prop_width($src_height);
                $src_h = $src_height;
                $src_x = intval(($src_width - $src_w) / 2);
                $src_y = 0;

            } else {
                $src_w = $src_width;
                $src_h = $this->get_prop_height($src_width);
                $src_x = 0;
                $src_y = intval(($src_height - $src_h) / 2);
            }

            return imagecopyresampled($this->image, $src, 0, 0, $src_x, $src_y, $this->width, $this->height, $src_w, $src_h);

        } else
            return false;
    }
1047716
private function import_return_value( $src ){
		// evaluate full runtime function call
		eval( '$value = '.$src );
		if( is_object($value) ){
			return 'unserialize('.var_export(serialize($value),1).');';
		}
		else {
			return var_export($value,1).';';
		}
	}
362398
protected function _getPublicSrc($src)
    {
        return $this->view->cdn ? $this->view->cdn . $src : $this->view->baseUrl . $src;
    }
755797
public function htmlImage($src, array $attributes = array()) {
        $attributes['src'] = $src;
        $html = '<img' . $this->_htmlAttribs($attributes) . '>';
        return $html;
    }
2192
function minify(src) {
       // remove comments
       src = src.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, "$1"); // Remove leading and trailing whitespace from lines

       src = src.replace(/(\\n\s+)|(\s+\\n)/g, ""); // Remove line breaks

       src = src.replace(/(\\r|\\n)+/g, ""); // Remove unnecessary whitespace

       src = src.replace(/\s*([;,[\](){}\\\/\-+*|^&!=<>?~%])\s*/g, "$1");
       return src;
     }
201366
protected function minify($html)
    {
        $html = str_replace('<?xml encoding="UTF-8">', '', $html);

        $html = trim(preg_replace('/\s+/', ' ', $html));

        $html = str_replace('> <', '><', $html);

        return str_replace(array(' />', '/>'), '>', $html);
    }