Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minify_html=true does not minify embedded CSS and JS #1765

Closed
JeremyBarbosa opened this issue Feb 13, 2022 · 2 comments
Closed

minify_html=true does not minify embedded CSS and JS #1765

JeremyBarbosa opened this issue Feb 13, 2022 · 2 comments

Comments

@JeremyBarbosa
Copy link
Contributor

Bug Report

Environment

Zola version: 0.15.3

Expected Behavior

When setting minify_html = true in config.toml, it is expected that the entire generated HTML file would be minified, as mentioned in the documentation for the minify_html:
"When set to "true", the generated HTML files are minified."

For example, the following code block:

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <style>
    p {
      color: white;
      margin-left: 10000px;
    }
  </style>
  <script>
    alert("Hello World!");
    console.log("Some information: %o", information);
  </script>
</head>
<body>


    <p>Example blog post</p>

  FOO BAR
</body>
</html>

Should create this:

<!doctype html><html><head><meta charset=utf-8><style>p{color:#fff;margin-left:10000px}</style><script>alert("Hello World!"),console.log("Some information: %o",information);</script><body><p>Example blog post</p> FOO BAR

Current Behavior

Currently, embedded CSS and JavaScript (in things such as <style> and <script> tags) are not minified. For example, the following code block:

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <style>
    p {
      color: white;
      margin-left: 10000px;
    }
  </style>
  <script>
    alert("Hello World!");
    console.log("Some information: %o", information);
  </script>
</head>
<body>


    <p>Example blog post</p>

  FOO BAR
</body>
</html>

Creates this:

<!doctype html><html><head><meta charset=utf-8><style>p {
      color: white;
      margin-left: 10000px;
    }</style><script>alert("Hello World!");
    console.log("Some information: %o", information);</script><body><p>Example blog post</p> FOO BAR

Step to reproduce

  1. Include embedded CSS or JS in an HTML template
  2. Set minify_html = true in config.toml
  3. Inspect the output of zola build
@Keats
Copy link
Collaborator

Keats commented Apr 26, 2022

This won't be fixed for now. The minifier lib we're using requires bundling Go.

@Keats Keats closed this as completed Apr 26, 2022
@JeremyBarbosa
Copy link
Contributor Author

Great news! The minifier library no longer relies on js-esbuild and therefore the Go compiler! It instead uses its own js-minify library now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants