Skip to content

Instantly share code, notes, and snippets.

@pathawks
Last active November 20, 2023 13:52
Show Gist options
  • Save pathawks/1390115 to your computer and use it in GitHub Desktop.
Save pathawks/1390115 to your computer and use it in GitHub Desktop.
Liquid Minify

Simply call this template from your master Jekyll template, and your site will be (more or less) minified

{% capture content %}{{ content | replace:' ',' ' }}{% endcapture %}{% capture content %}{{ content | replace:' ',' ' }}{% endcapture %}{% capture content %}{{ content | replace:' ',' ' }}{% endcapture %}{% capture content %}{{ content | replace:' ',' ' }}{% endcapture %}{% capture content %}{{ content | replace:' ',' ' }}{% endcapture %}{% capture content %}{{ content | replace:' ',' ' }}{% endcapture %}{% capture content %}{{ content | replace:' ',' ' }}{% endcapture %}{% capture content %}{{ content | replace:' <link ','<link ' }}{% endcapture %}{% capture content %}{{ content | replace:' <meta ','<meta ' }}{% endcapture %}{% capture content %}{{ content | replace:' <title>','<title>' }}{% endcapture %}{% capture content %}{{ content | replace:' <head>','<head>' }}{% endcapture %}{% capture content %}{{ content | replace:' </head>','</head>' }}{% endcapture %}{% capture content %}{{ content | replace:' <body','<body' }}{% endcapture %}{% capture content %}{{ content | replace:' </body>','</body>' }}{% endcapture %}{% capture content %}{{ content | replace:' <div','<div' }}{% endcapture %}{% capture content %}{{ content | replace:' </div>','</div>' }}{% endcapture %}{% capture content %}{{ content | replace:' <p','<p' }}{% endcapture %}{% capture content %}{{ content | replace:' </p>','</p>' }}{% endcapture %}{% capture content %}{{ content | replace:' <article','<article' }}{% endcapture %}{% capture content %}{{ content | replace:' </article>','</article>' }}{% endcapture %}{% capture content %}{{ content | replace:' <h1','<h1' }}{% endcapture %}{% capture content %}{{ content | replace:' </h1>','</h1>' }}{% endcapture %}{% capture content %}{{ content | replace:' <h2','<h2' }}{% endcapture %}{% capture content %}{{ content | replace:' </h2>','</h2>' }}{% endcapture %}{% capture content %}{{ content | replace:' <nav','<nav' }}{% endcapture %}{% capture content %}{{ content | replace:' </nav>','</nav>' }}{% endcapture %}{{ content }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment