I’m beginning to learn javascript and I wrote an infinite loop
<script>
while(1==true){
document.write("hello world");
}
</script>
I ran top -d .5 from the commandline and didn’t see this script take up CPU.
I then created an infinite loop in .php
<?php
while(1==true){
echo "Hello World";
}
?>
I ran top -d .5 from the commandline and saw this .php script take up CPU.
This leads me to believe that when an infinite loop written in javascript runs, it only taxes your computer’s resources, not the server’s (I guess that’s why they call it a client-side language.) Can someone confirm this?
And more generally, does this mean that all the interpreting of javascript taxes only your computer’s resources, not the server’s?
True and true.
When making a loop in PHP wich is server-side you will take up resources from your server. When doing scripting in “javascript” you will use the clients resources, unless you of course do serverside calls. In most modern browsers Javascript just uses the browsers memory wich means that you cannot take up all computer resources before your browser will quit on you.
Best regards
Jonas