const button = document.querySelector("button");
const evtSource = new EventSource("sse.php");
button.onclick = () => {
console.log("Connection closed");
evtSource.close();
};EventSource: close() method / notebook
EventSource: close() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.