You could probably do something like this to make Espruino head through it 32 bits at a time instead of 8:
masked = new Uint32Array(1+((msg.length+3)>>2));
var m8 = new Uint8Array(masked.buffer,0,4+msg.length);
m8.set(mask,0);
m8.set(msg,4);
var m = masked[0];
for (var i=masked.length-1;i>0;i--)masked[i]^=m;
// E.mapInPlace could be even faster here
this.socket.write(m8);
But you'd have to have a play around yourself - I haven't tested that.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Chances are it's this code that is slowing things down:
https://github.com/espruino/EspruinoDocs/blob/master/modules/ws.js#L230
You could probably do something like this to make Espruino head through it 32 bits at a time instead of 8:
But you'd have to have a play around yourself - I haven't tested that.