Comments (8)
As far as I know, this is intended, compressHTML
is never supposed to change the visual output of the website
from docs.
No (well it's not supposed to at least?), because spaces in this context always get collapsed to one. That's why Prettier formats
<span>
Something
</span>
into
<span> Something </span>
because they end up with the same visual result, since the number of whitespace doesn't matter.
And it would be useful to still have at least an opt-in mode where all whitespace is collapsed (similar to JSX). Currently this does not seem achievable even with a Vite plugin (transformIndexHtml does not get called on Astro-generated HTML).
I agree, that'd be cool! Essentially turning the HTML into JSX, ha.
from docs.
Yeah, that makes sense to me. Thanks for the quick response
Edit: created discussion withastro/roadmap#868
from docs.
Isn't it already changing the visual output by removing indentation?
In any case, the current documentation is misleading.
And it would be useful to still have at least an opt-in mode where all whitespace is collapsed (similar to JSX). Currently this does not seem achievable even with a Vite plugin (transformIndexHtml
does not get called on Astro-generated HTML).
from docs.
Moving this issue to docs, since it's a docs issue in the end. It should be documented that compressHTML
only compresses HTML in lossless manner and that in order to preserve the visual of the authored HTML, it might keep some whitespaces.
from docs.
@mayank99 Feel free to create a roadmap discussion https://github.com/withastro/roadmap/discussions with the compressHTML
idea!
from docs.
Worth also noting that the prettier plugin will sometimes forcibly insert meaningful whitespace, by breaking up long lines.
(If there was a way to trim whitespace, it wouldn't be an issue)
from docs.
Thanks for the discussion here!
Would be happy if someone wanted to make a PR to adjust the wording per Erika's note that
compressHTML only compresses HTML in lossless manner and that in order to preserve the visual of the authored HTML, it might keep some whitespaces.
The change must be made here (in the main astro repo):
https://github.com/withastro/astro/blob/main/packages/astro/src/%40types/astro.ts#L721
And maybe update the content to something like:
This is an option to minify your HTML output and reduce the size of your HTML files. Astro removes whitespace from your HTML, including line breaks, from .astro components in a lossless manner. This means that some whitespace may be kept to preserve the visual rendering of your HTML. This occurs both in development mode and in the final build. To disable HTML compression, set the compressHTML flag to false.
from docs.
Related Issues (20)
- Zod compatibility HOT 3
- Document View Transition events fields HOT 9
- Abount Fontsource package name HOT 2
- View Transitions Script Behavior HOT 1
- Double/triple click headings copy issues HOT 2
- Getting errors creating a new project
- The remark config documentation misses some important information HOT 3
- Clarify how to implement social image URLs HOT 4
- Missing explanation about "themes" from ShikiConfig in syntax highlighting HOT 2
- ⚠️ Issue - The implementation of themes from Shiki is not working properly. HOT 1
- Add a bit more help text to client:only description
- Give us feedback form Appearance is not in line with Astro Doc Styling HOT 1
- RTL Docs `Inline Code Snippet` need to be always LTR. HOT 4
- Deploying to GitHub Pages is problematic/flakey HOT 1
- Prettier plugin content is incorrect. HOT 2
- Middleware: unclear that reading cookies/headers behaviour HOT 1
- Improve documentation on fallback content for slots HOT 3
- Unclear refactoring task
- Script Tag CDNs with View Transitions HOT 1
- `prose-p:text-justify` makes recipe less usable HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs.