Reorganised JavaScript wrapper.