Both options are okay (I would be more happy with the B though).
My goal is a simple client-server communication, and I think, that websocket still doesn't stand on two legs.
I appreciate your answer.
is the best as a starter, because it highlights the important part. Later on you may want to go for some more advanced JS library to produce production-ready code faster.