JS backend: small refactoring