Skip to content

Commit fb03441

Browse files
committed
assets: live-reload
1 parent fdfd825 commit fb03441

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/assets/live-realod.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @file live-reload.js
3+
* @author Krisna Pranav
4+
* @brief Live Reload Functionality
5+
* @version 1.0
6+
* @date 2024-02-07
7+
*
8+
* @copyright Copyright (c) 2025 Krisna Pranav, Moon Developers
9+
*
10+
*/
11+
12+
(function connect(reload = false) {
13+
let closing = false;
14+
15+
window.addEventListener("beforeunload", () => {
16+
closing = true;
17+
});
18+
19+
var ws = new WebSocket("ws://" + location.host);
20+
21+
ws.onopen = () => {
22+
if (reload) {
23+
window.location.reload();
24+
}
25+
};
26+
})

0 commit comments

Comments
 (0)