Consider enabling whitespace trimming in the Jinja2 env #3309
Replies: 3 comments 2 replies
-
@oprypin Sorry for the mention, I just noticed that you're currently active. Could you please state your opinion on this matter? |
Beta Was this translation helpful? Give feedback.
-
Sure it can be an opt-in feature for themes. Otherwise I think it can break stuff. The importance of this is not that big, (same for minification actually) because everything should be served gzipped - you should measure that. |
Beta Was this translation helpful? Give feedback.
-
I think it's safe if a theme enables the |
Beta Was this translation helpful? Give feedback.
-
Hi 👋,
kind of a weird feature to ask for, I know, but I got the idea after looking at the default source code of our built documentation page. We're using the Material theme, and for our deployment we're using the
minify
plugin too.But many people don't do that, either because they don't think about this, or don't want to increase their build time with the plugin. So their pages waste network and processing time globally ❗
However, I checked and it's possible to enable simple trimming directly in the env.
Testing it with a hook:
mkdocs new
with the Material theme got reduced from 11,795 down to 10,539 characters, so roughly a 10% reduction.Our homepage, which uses different features of Material etc. got reduced from 83,975 down to 65,449 characters, so roughly a 20% reduction,
The issue lies of course in the Material theme's lack of whitespace management, but this seems like the less painful solution in general if MkDocs would enable this Jinja2 feature by default.
The build time didn't change for me with this setting enabled.
EDIT:
Or perhaps it would be possible to add it as an opt-in feature for the themes 🤔
Beta Was this translation helpful? Give feedback.
All reactions