KakapoWP KakapoWP
Help Center/Performance/Shrink HTML, CSS and JavaScript

Shrink HTML, CSS and JavaScript

Applies to: Kakapo Performance· 3 min read

Minify shrinks the document that goes to the browser: superfluous whitespace, comments and empty lines are dropped. If the page cache is active, this already happens when the file is stored, otherwise via an output buffer in the frontend.

The three switches

  1. In the left sidebar under “Speed” you will find the “Minify” item — that is where the three switches sit one below the other.
  2. “Minify HTML” removes HTML comments, whereby conditional IE comments are left in place, and shortens the whitespace between tags as well as multiple spaces in the text. Switched on by default.
  3. “Minify inline CSS” tightens <style> blocks: comments gone, whitespace collapsed, characters around { } : ; , tightened. Switched off by default.
  4. “Minify inline JS” tightens inline <script> blocks line by line. Switched off by default.

What stays untouched

  • External scripts with a src attribute; they contain only the address and no code
  • Script blocks with a different type, such as JSON-LD as application/ld+json
  • Content in <pre> and <textarea>
  • CSS comments that begin with /*!
The JS minification does not pull any tokens together. It only removes empty lines and indentation from real script blocks, so that JavaScript's automatic semicolon insertion does not break anything.

When the output buffer takes effect

Without the page cache, buffering only happens for GET requests in the frontend; the admin area and feeds are left out. An output is only processed from 255 characters onwards and only if it contains a closing </html>. If all three switches are off, the document stays unchanged.

With the page cache active, the minification only runs for requests that are allowed to be cached. Logged-in users and excluded addresses then get unchanged HTML.
Was this article helpful?