js: deferred wait