JS backend: reorder functions as in ImplementationBodyCodegen