Why does mod_proxy_html mangle my Javascript?
It doesn’t. Your javascript is simply too badly malformed, and libxml2’s error correction isn’t what you expect! Check it with a validator, or with libxml2’s xmllint –html (which uses the same parser as mod_proxy_html). Here is a fuller explanation. The best fix for this is to remove the javascript from your markup, and import it from a separate .js file. If you have an irredeemably broken publishing system, you may have to upgrade to mod_publisher or resort to a markup-blind filter such as mod_line_edit, mod_substitute or mod_sed.