RejectedSoftware Forums

Sign up

whitespace in HTML

Should vibe.d have an option for stripping all whitespace between HTML tags?
For example

res.render!("index.dt", req);         // pretty formatted HTML
res.renderStripped!("index.dt", req); // stripped HTML

or

res.render!("index.dt", req);         // stripped HTML
res.renderPretty!("index.dt", req);   // pretty formatted HTML

Re: whitespace in HTML

Am 28.10.2013 12:04, schrieb Jack Applegame:

Should vibe.d have an option for stripping all whitespace between HTML tags?
For example

res.render!("index.dt", req);         // pretty formatted HTML
res.renderStripped!("index.dt", req); // stripped HTML

or

res.render!("index.dt", req);         // stripped HTML
res.renderPretty!("index.dt", req);   // pretty formatted HTML

The only thing that would be important is to keep some whitespace in
places where it was before, so that the final rendered HTML isn't
affected. So maybe starting with just stripping the indentation is the
safest approach. It could then be extended to strip around non-inline
HTML elements, which may then still break some pages with CSS, but that
may be acceptable...

BTW I've made a quick test with some pages on vibed.org and get about
15% savings for the plain HTML and about 5% for the gzipped versions
(and about 10% plain and 3% gzipped when only stripping indentation).

Since squeezing out every byte won't matter for most applications,
though, and also to keep backwards compatibility, I'd go with variant
number 1 and keep the current behavior as the default.