<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>David Cramer's Blog - Latest Comments in Spaceless HTML in Django</title><link>http://davidcramer.disqus.com/</link><description></description><atom:link href="https://davidcramer.disqus.com/spaceless_html_in_django/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 23 Feb 2009 09:28:23 -0000</lastBuildDate><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-38940768</link><description>&lt;p&gt;There are bigger fish to fry.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">lericson</dc:creator><pubDate>Mon, 23 Feb 2009 09:28:23 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-38940767</link><description>&lt;p&gt;I suggest this tag should be effective only on setting debug=False&lt;br&gt;Debugging html on viewing html source code is quite common. &lt;br&gt;That's what I did ;)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martyn Clement</dc:creator><pubDate>Thu, 08 Jan 2009 06:54:58 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-38940766</link><description>&lt;p&gt;Shame it messes up the pre and textarea tags :( was gonna use it otherwise.&lt;/p&gt;&lt;p&gt;Intersting idea though!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dougal Matthews</dc:creator><pubDate>Sat, 20 Dec 2008 23:06:43 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-38940765</link><description>&lt;p&gt;Shame it messes up the &lt;/p&gt;&lt;pre&gt; and  tags :( was gonna use it otherwise.&lt;br&gt;&lt;br&gt;Intersting idea though!&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dougal Matthews</dc:creator><pubDate>Sat, 20 Dec 2008 23:06:04 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4296672</link><description>&lt;p&gt;The whitespace tag is really simple, it just finds the end of one tag and the beginning of another with whitespace in between, and removes said whitespace. It looks like it doesn't have any special cases, so it unfortunately affects textarea and pre tag content.&lt;/p&gt;&lt;p&gt;see: &lt;a href="http://code.djangoproject.com/browser/django/trunk/django/utils/html.py#L60" rel="nofollow noopener" target="_blank" title="http://code.djangoproject.com/browser/django/trunk/django/utils/html.py#L60"&gt;http://code.djangoproject.c...&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Chris Kelly</dc:creator><pubDate>Tue, 09 Dec 2008 17:15:06 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4202306</link><description>&lt;p&gt;We GZIP as well. Sadly, everyone's still not on broadband today, so even shaving off 5 or 10k from the request can be quite useful (especially when the amount of time it takes to do that is immeasurable).&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">David Cramer</dc:creator><pubDate>Fri, 05 Dec 2008 06:55:54 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4166178</link><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;I'm curious: why outputting whitespace-less HTML when you could just use gzip compression on the server for HTML, XML, CSS and JavaScript, and get better results (like from 300 kB -- not kb ;) -- to, say, 120 kB)? Did you do some performance testing regarding that?&lt;/p&gt;&lt;p&gt;Unless gzipping your text output has a clear performance cost, I would keep my HTML code with whitespace (if not perfect, then at least decently readable code). Makes it easier to debug when you need to check the real thing (Firebug only shows what Firefox understands, not what it gets from the server).&lt;/p&gt;&lt;p&gt;Do you happen to use this method, then gzip (through mod_deflate for instance)? If so, how much do you save compared to a gzipped version with all whitespace intact?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Florent V.</dc:creator><pubDate>Thu, 04 Dec 2008 10:52:26 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4127244</link><description>&lt;p&gt;Very nice and simple trick. Thanks&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Bartek</dc:creator><pubDate>Tue, 02 Dec 2008 10:12:24 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4126111</link><description>&lt;p&gt;I wrote this snippet:&lt;br&gt;&lt;a href="http://www.djangosnippets.org/snippets/1055/" rel="nofollow noopener" target="_blank" title="http://www.djangosnippets.org/snippets/1055/"&gt;http://www.djangosnippets.o...&lt;/a&gt;&lt;br&gt;to (very) efficiently whitespace optimize inline CSS which might be interesting for you and your Jinja too.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter Bengtsson</dc:creator><pubDate>Tue, 02 Dec 2008 08:45:18 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4125707</link><description>&lt;p&gt;or the end*&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Roger</dc:creator><pubDate>Tue, 02 Dec 2008 07:59:53 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4125704</link><description>&lt;p&gt;The appropriate place for cached content to be effected would be at the start of the end? :-/&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Roger</dc:creator><pubDate>Tue, 02 Dec 2008 07:59:27 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4125221</link><description>&lt;p&gt;I had problems with highlighted (pygments) text in pre-tags which results in unindented code *cry*. But that's a very special condition.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Mahner</dc:creator><pubDate>Tue, 02 Dec 2008 06:40:32 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4125160</link><description>&lt;p&gt;Ups, I wasn't aware that there is a real "strip_spaces_between_tags" function. Sorry for the noise :D&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Mahner</dc:creator><pubDate>Tue, 02 Dec 2008 06:29:23 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4125147</link><description>&lt;p&gt;Have you confirmed this? I believe the whitespace tag is designed to avoid that, but I haven't fully tested it.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">David Cramer</dc:creator><pubDate>Tue, 02 Dec 2008 06:27:09 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4125132</link><description>&lt;p&gt;The drawback of this is, that it also steals the whitespace in pre and textarea tags.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Mahner</dc:creator><pubDate>Tue, 02 Dec 2008 06:25:18 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4125017</link><description>&lt;p&gt;Note that Content-Type will usually be 'text/html; charset=utf-8', not just 'text/html' (since Content-Type without a charset is unsafe).&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mikkel Høgh</dc:creator><pubDate>Tue, 02 Dec 2008 06:05:00 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4123480</link><description>&lt;p&gt;Clever trick! Debuggers could always use firebug if they want it indented nice. Everyone should do this + gzip + expires header if plausible&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Andreas</dc:creator><pubDate>Tue, 02 Dec 2008 02:32:54 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4122433</link><description>&lt;p&gt;It's mostly indentation that actually contributed to the whitespace :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">David Cramer</dc:creator><pubDate>Tue, 02 Dec 2008 00:57:25 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4122390</link><description>&lt;p&gt;So... every third byte was whitespace?  That's a bit hard to believe, even as a worst-case.  Still, if you saw improvements, then my congratulations.&lt;/p&gt;&lt;p&gt;I would suggest, though (as I see others have), that people facing the same problem have a look at simply gzipping their text-based output at the webserver level.  Since the action's probably happening on the webhead either way, it's unlikely to be much more costly in CPU terms, and it's even simpler to implement than your solution (it typically just takes a line or two in .htaccess if you're using Apache).  Gzipping will certainly remove any overhead that whitespace represents.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tom</dc:creator><pubDate>Tue, 02 Dec 2008 00:52:41 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4121088</link><description>&lt;p&gt;Does mod_deflate allow removing the extra whitespace? In your example you are correct, that it's not a huge savings for that individual request, and gzip I would highly recommend, but the CPU time is negligible. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">David Cramer</dc:creator><pubDate>Mon, 01 Dec 2008 23:13:39 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4116051</link><description>&lt;p&gt;Very interesting thoughts.  I'll have to play around with it sometime.  Thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Josh</dc:creator><pubDate>Mon, 01 Dec 2008 21:28:13 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4115456</link><description>&lt;p&gt;I've considered this before, but wondered if there was much benefit over gzip (which I would recommend using even with whitespace stripping).  Does a whitespace-removed, gzipped response save enough space to justify the (admittedly reasonable) CPU cost of whitespace-removal?&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">danielnaab</dc:creator><pubDate>Mon, 01 Dec 2008 21:19:53 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4115389</link><description>&lt;p&gt;Is that really worth it?&lt;/p&gt;&lt;p&gt;taking a file:&lt;br&gt;index.html - 91565 bytes&lt;/p&gt;&lt;p&gt;code:&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; f = open('index.short', 'w')&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; f.write( short( file( 'index.html' ).read() ).encode('utf-8') )&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; f.close()&lt;/p&gt;&lt;p&gt;produces:&lt;br&gt;index.short - 69915&lt;/p&gt;&lt;p&gt;and my favorite - gzip:&lt;br&gt;index.gz - 14709&lt;br&gt;index.short.gz - 13319&lt;/p&gt;&lt;p&gt;examples from &lt;a href="http://zena.centrum.cz" rel="nofollow noopener" target="_blank" title="zena.centrum.cz"&gt;zena.centrum.cz&lt;/a&gt; where we have some nasty whitespace in our HTML...&lt;/p&gt;&lt;p&gt;Knowing this, I would take mod_deflate in (insert your favorite web server) over any python space stripping anytime...&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Honza</dc:creator><pubDate>Mon, 01 Dec 2008 21:18:40 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4112472</link><description>&lt;p&gt;I like it a lot.  I have been wondering if there was an easy way to do this, and there is.  I will definitely have use for this soon.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Sam McDonald</dc:creator><pubDate>Mon, 01 Dec 2008 20:24:24 -0000</pubDate></item><item><title>Re: Spaceless HTML in Django</title><link>http://cramer.io//369/spaceless-html-in-django.html#comment-4112333</link><description>&lt;p&gt;Pretty hot yet simple. Thanks Mistar Cramar.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Subsume</dc:creator><pubDate>Mon, 01 Dec 2008 20:13:41 -0000</pubDate></item></channel></rss>