question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Minify prerendered HTML (and app.html?)

See original GitHub issue

sapper export minifies the generated HTML. Perhaps we should do the same thing here?

// svelte.config.cjs
module.exports = {
  kit: {
    prerender: {
      minify: true
    }
  }
};
// svelte.config.cjs
module.exports = {
  kit: {
    prerender: {
      minify: {
        // manually specify options (https://www.npmjs.com/package/html-minifier)
        collapseBooleanAttributes: true
        // ...
      }
    }
  }
};

We could potentially do the same thing for src/app.html, though the benefits are less pronounced.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:17
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
Conduitrycommented, Mar 18, 2021

Being able to control the minification options (or disabling it entirely) sounds good, as this is one of the requested Sapper features that we deferred on because of a lack of a sane way to handle configuration.

I have mixed feelings about whether this should be enabled by default for prerendered sites. It’s probably a good idea, but then it’s also been the subject of a whole lot of invalid Sapper bugs.

I agree that it’s probably only a good idea to include this on HTML that can be minified during build time and not at runtime.

0reactions
Rich-Harriscommented, Apr 25, 2021

I’d like it if it was a bit more turnkey but it does seem very difficult to offer sensible defaults. Without configuration it won’t do a whole lot for you. So it probably doesn’t make sense to weigh the package down with a dependency that won’t do very much for most people.

Read more comments on GitHub >

github_iconTop Results From Across the Web

minifyHtml Plugin - Scully.io
This postRenderer plugin for Scully will minify the HTML of your prerendered pages. Removing unnecessary code will decrease the size of your files....
Read more >
Html-minifier NPM - npm.io
html -minifier v4.0.0 · HTMLMinifier · Minification comparison · Options Quick Reference · Special cases · Installation Instructions · Usage · Running benchmarks....
Read more >
Pre-rendering Angular Applications - Blog - Brecht Billiet
Learn how to use Server-side rendering to prerender our Angular ... the HTML even more, we could use an HTML minifier like this...
Read more >
Prerendering Explained - Netlify
Web crawlers are also trained to read HTML, but not trained to read JavaScript Single Page app as something more than just one...
Read more >
Isomorphic Support | Enact
The app's initial state is rendered via React into an HTML string and embedded statically into the index.html file. Why Prerender? Having the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found