Improve JS handling

see #130