The right solution to this problem in general is to not do layout manually in script and instead do declarative layout in CSS. That, of course, requires more powerful CSS features, but those are happening. Several browsers now shipping calc() unprefixed and flexbox is well on its way; those should help a lot between the two of them...