As I dive into learning javascript, I decided to test out an infinite loop.
<script>
while(1==true){
document.write("hello world");
}
</script>
Curiously, when I ran top -d .5
from the command line, I didn't notice any significant CPU usage from this script.
To further investigate, I created a similar infinite loop in PHP.
<?php
while(1==true){
echo "Hello World";
}
?>
This time, running top -d .5
showed that the .php script was indeed consuming CPU resources.
This observation made me wonder if executing an infinite loop written in javascript only impacts the individual user's computer resources rather than the server's (hence its classification as a client-side language). Can anyone validate this?
Furthermore, does this imply that processing javascript tasks solely utilizes the local machine's resources and not the server's?