posthtml / htmlnano

Modular HTML minifier, built on top of the PostHTML

Home Page:https://htmlnano.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mergeScripts skip block?

spacedawwwg opened this issue · comments

Is there a way to use mergeScripts but skip a block?

use case: I have a <script> in the head that needs to be in the head, but the rest of the script blocks can be merged

some kind of flag on the tag would be good maybe?

Sure. Just add some different class to it:

<html lang="en">
<head>
    <script class="foob">alert(1)</script>
    <script>alert(2)</script>
</head>
<body>
    <script>alert(3)</script>
    <script>alert(4)</script>
</body>
</html>

would get minified to

<html lang="en">
<head>
    <script class="foob">alert(1);</script>
</head>
<body> 
    <script>alert(2),alert(3),alert(4);</script>
</body>
</html>

Let me know if this works for your use-case!