HTML Web Socket API enable communication between the client (browser) and the server over a single, long lived connection. This is different from HTTP, where a new connection is made for each request/response.
<!DOCTYPE html> <html lang="en"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>SakalaCode WebSocket with Example</title> </head> <body> <h2>WebSocket Chat With Example</h2> <div> <label for="message">Enter Message:</label> <input type="text" id="message"> <button on click="sendMessage()">Send</button> </div> <h3>Messages:</h3> <ul id="messagesList"></ul> </body> </html>