Backport PR #4178: add missing data_javascript

Note that javascript is still excluded from html output by default,
but this makes it possible to include javascript output in custom templates.

candidate for backport to 1.1
Backport PR #4043: don't 'restore_bytes' in from_JSON

It makes no sense to turn base64-encoded unicode strings into base64-encoded byte strings.
I can't think why we do this, but we should be very careful about testing before merging this fix.

fixes the issue tested in #4036.