I'm developing an online game fully in javascript(both server and client). Due to the fact that people can make custom maps/servers in my game, one of the options for the base server script to upload the map file to the client upon connection is through websockets, but I haven't found anywhere how to limit websockets speed so the server won't lag every time a new person connects and download its map.
One way to getting around this that I had thought was splitting the buffer where the map file is saved(I read it using fs.readFileSync then I make a buffer where it stays until requested) into many small buffers, then upload only one of them per second to the client, thus creating a "fake" upload speed limit for the server, theoretically avoiding lags and/or crashes.
My question is: is that a good idea? Would that work as intended?