function elementWidth() { return container ? container.clientWidth : nativeEl.offsetWidth; } might be better