Simplify the javascript API code.