html 删除注释
When it comes to sending content to users, I'm of the belief that less is more. There's no reason for HTML comments to be sent down to the user -- they simply bloat the payload. I remove unwanted HTML comments within my WordPress theme, so I thought I'd share the regex that does it:
在向用户发送内容时,我相信少即是多。 没有必要将HTML注释发送给用户-它们只是使有效负载膨胀。 我在WordPress主题中删除了不需要HTML注释,因此我想与他人分享正则表达式:
// Remove unwanted HTML commentsfunction remove_html_comments($content = '') { return preg_replace('/ /', '', $content);}
That handy function, paired with output buffering, allows me to remove HTML comments from anywhere within the page. Less load, less cruft for mobile users!
该便捷功能与输出缓冲配合使用,使我可以从页面中的任何位置删除HTML注释。 减轻负载,减少移动用户的负担!
翻译自:
html 删除注释