Revert "Remove unnecessary JavaScript jiggery-pokery"

Too many uncertainties around IE7. We can revisit later.

This reverts commit f98f153bf82bdcfb7eb17be664ae6a2b1ee22921.