Better encoding of javascript
Fixes #2988
Merge pull request #3269 from tractorcow/pulls/3.1/convert-js-enhancements

Better encoding of javascript