Thread tagged as: Question, Problem, Redactor

Redactor II Textarea Whitespace


Does anyone using Redactor II find that loads of whitespace is added when saving a textarea?

Also the Heading 4 format when used shows the text as all uppercase in the editor (not on the frontend) when all the other Heading format options are styled normally.

I am using Redactor II as provided and not modified in anyway.

Neil Duddridge

Neil Duddridge 1 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What do you mean by whitespace here? Is there any HTML output?

Hi Drew,

The HTML is intact and renders fine but for some reason loads of white space has been added. I've got back in the editor

View the source of this page

The swathes of white space you start to see is from a single within a single textarea

Here is what I see in Perch

Drew McLellan

Drew McLellan 2638 points
Perch Support

Obviously would be nicer if it didn't do that, but once it's been gzipped across the wire there should be no detrimental effect.

Thanks Mike/Drew,

I am running Gzip so not an issue, however I also found this code which I am using to minify the html, something I've not used before but seeing how it goes. I've put it at the top of my global.header file

function sanitize_output($buffer) {

        $search = array(
        '/\>[^\S ]+/s',     // strip whitespaces after tags, except space
        '/[^\S ]+\</s',     // strip whitespaces before tags, except space
        '/(\s)+/s',         // shorten multiple whitespace sequences
        '/<!--(.|\s)*?-->/' // Remove HTML comments

        $replace = array(

        $buffer = preg_replace($search, $replace, $buffer);

        return $buffer;

Drew McLellan

Drew McLellan 2638 points
Perch Support

All you're doing there is slowing your site down for no benefit.