Web APIs

EventSource.prototype.close()

Try the free JavaScript compiler

Aborts the connection and sets readyState to CLOSED, preventing reconnection by that instance.

Formal Syntax & Structure

javascript syntaxjavascript
source.close()

Return Value

undefined

Aborts the connection and sets readyState to CLOSED, preventing reconnection by that instance.

Working Example

Example Snippetjavascript
(async () => {const es=new EventSource("/events");es.close();console.log(es.readyState===EventSource.CLOSED);})()
JavaScript Reference