title: Minify JS via PHP using regex
body: <p>will anyone advise me about JS minification? I try to create it, but without success. We will show you on the example: <code>https://code.jquery.com/jquery-3.3.1.js</code></p>
  
  <p><strong>I want</strong></p>
  
  <ol>
  <li>Remove all comments except http &amp; https or inside strings</li>
  <li>Merge the code into one line</li>
  <li>Remove all unnecessary spaces</li>
  </ol>
  
  <p>I have tried a lot of examples from the Internet, and it has always been a mistake. Not even any minifier I found did it without error, so I want to write a simple own minifier. I do not want to use any plugin. I just want a clean regex.</p>
  
  <p>Can you try to minify this example as much as possible? Whether it's spaces, comments or some other improvement or trickery?</p>
  
  <p><strong>So far I have this, and it does not work either</strong></p>
  
  <pre><code>    '(\/\/[^\n\]*[\n\r]+)' =&gt; ''
      '/\/\*[\s\S]*?\*\//' =&gt; ''
      '#[\r\n]+#' =&gt; ''
      '/ {2,}/' =&gt; ''
  </code></pre>