JavaScript layout algorithms