Enable JavaScript in Blogger's Dynamic Views

Blogger's new dynamic views strip all script tags. Formerly it was possible to include <script> tags at will in the HTML code of each post without hindrance, making Google's Blogger service a great host for blogging-folk who frequently include source code with in-place executable web-content and demonstrations.

The unavoidable solution so far has been to migrate all <script> tags into <code>-tags. To be clear, this is a pre-requisite one must do.

So far the tag processing in this blog is as follows:

  • render all <pre> tags through the syntax-processor highlighter.js .
  • <code> tags are css styled for emphasis but are displayed inline and not preformatted text, that is they do not conserve whitespaces such as line breaks and tabs. 
  • <pre><code> nested tags will yield highlighted, preformatted text
  • <code data-src=""> will load remote scripts
  • <code data-store> will merely contain custom ASCII data using the custom HTML5 data- attributes. HTML5 does in principle have a data tag, but it quite OK to pass it up for now:
Associates to its content a machine-readable equivalent . (This element is only in the WHATWG version of the HTML standard, and not in the W3C version of HTML5).

Finally, and the reason for this post,  <code data-store> tags are used with a CDATA container, which will be injected by a site-script as JavaScript, thus restoring the usual behavior. Alternatively one can set  <code data-store=cdata>

This works as follows:

Showing an Commented Container to allow HTML and XHTML compliance

As always this post-processing script is triggered by a timeout function, since google's dynamic templates themselves inject their entire content later on. I do not know if there is a custom fired event that one could listen to. Google's template itself used a setimeout hack, which is why i stuck with it. Later, I could simply listen to a DOMNodeInserted, DOMNodeInsertedIntoDocument or DOMCharacterDataModified changenode event of a poignant Node.


To quickly find posts containing scripts I simply search for /script.