JS utility to size boxes