Deprecate the spaceless filter for the following reasons:
The performance is bad (as the work is done at runtime via a regexp)
Optimizing the size of an HTML doc server side is "almost never" a good idea (compression is better and enough)
There are some edge cases where you want to keep some spaces (see #3576)
Controlling whitespace is possible and fine-grained via the dedicated Twig modifiers on {{ }}
If someone find it useful, re-creating it is trivial (return trim(preg_replace('/>\s+</', '><', $content ?? ''));),
but with so many caveats and not so many use cases, I think it does not belong to core.
Closes #3576
Deprecate the
spaceless
filter for the following reasons:{{ }}
If someone find it useful, re-creating it is trivial (
return trim(preg_replace('/>\s+</', '><', $content ?? ''));
), but with so many caveats and not so many use cases, I think it does not belong to core.