使用js写一个方法对html进行压缩

29 阅读1分钟

"```javascript function compressHTML(html) { return html .replace(/[\r
\t]/g, '') // Remove newlines, carriage returns, and tabs .replace(/\s{2,}/g, ' ') // Replace multiple spaces with single space .replace(/>\s+</g, '><'); // Remove spaces between tags }

"