inlined scale fix javascript. Was causing 100ms slowdown at times