I am making a clock in JavaScript and part of it is of course the while loop to constantly update the time. I have searched this error up and it says that running a while loop makes JavaScript unresponsive. I don't know how to substitute the while loop and why I can't seem to put one there. Help would be greatly appreciated. Here is the error and code.
var today = new Date();
var hours;
var minutes;
var seconds;
var percentage;
var time;
var clock = document.getElementById("clockHeading");
while (true){
hours = today.getHours();
hours = hours*3600;
minutes = today.getMinutes();
minutes = minutes*60;
seconds = today.getSeconds();
seconds = seconds+minutes+hours;
percentage = seconds/48600;
percentage = String(percentage);
percentage = percentage+"%";
time = document.createTextNode(percentage);
clock.appendChild(time);
}
body{
font-family: "Raleway";
}
#clockHeading{
position: fixed;
top: 50%;
width: 100%;
text-align: center;
font-size: 200px;
}
<!DOCTYPE html>
<html>
<head>
<title>Percent Clock</title>
<link href="style.css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@300&display=swap" rel="stylesheet">
</head>
<body>
<h1 id="clockHeading"></h1>
<script type="text/javascript" src="clock.js"></script>
</body>
</html>