[Question] Tips on speeding up HTMLPurifier?
March 27, 2007 06:42PM

Some comments on how different config settings might affect the time taken for processing by HTMLPurifier would be helpful. For example, would processing be faster if Core.EscapeNonASCIICharacters is false, if HTML.AllowedElements is a long list, and so on.

HTMLPurifier is very good but slow compared, for example, to the humbler kses filter. I tested an XHTML string, almost completely valid, of about 3000 characters - with kses, 10 ms, with HTMLPurifier (default config), ~1300 ms.

With caching, slowness may not matter as such, but still...

Edited 1 time(s). Last edit at 04/02/2007 06:40AM by Ambush Commander.

Re: Tips on speeding up HTMLPurifier?
March 27, 2007 07:01PM

Hmm, I really don't know! HTML.AllowedElements shouldn't make any difference, Core.EscapeNonASCIICharacters will slow down things however.

Some of the most concrete things you can do to improve speed, you may want to ensure that iconv is installed and you're on PHP5 with DOM.

Any suggestions are patches that speed up the code would be welcome, but HTML Purifier is pretty heavyweight.

HTML Purifier, Standards Compliant HTML Filtering

Author:
Your Email:

Subject:

HTML input is enabled. Make sure you escape all HTML and angled brackets with < and >.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

<pre><![CDATA[
Place code here
]]></pre>

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}

Message: