Warm tip: This article is reproduced from serverfault.com, please click

What is the best way to freeze/lag a computer with JS

发布于 2020-08-14 23:25:06

As said in the title, I am looking for the best way to freeze a computer. I have done a bit of research, but was not able to find anything on this subject (probably because I'm using Yahoo).

I have made a program and it would be preferrable if the code was hidden and have a detect-inspect-element function from this question. Currently, my freeze function is just while(true){}, but I am looking for something way slower. I am on a chromebook and a while loop will only lag the current page.

I have seen people use history.pushState() to lag other pages and even make it hard to x out, but I was not able to replicate the inefficiency. Any help would be useful.

Questioner
the bad question account
Viewed
0
Dai 2020-08-15 07:48:30

You can't freeze a browser with JavaScript, by-design: the browser's JS engine will detect high CPU usage and abort, kill, interrupt, or suspend the offending JavaScript.

In ye olden days (pre IE6) when browser's JavaScript engines were tied-in with their window-message pumps, it was possible for a script to block all user interaction with a browser (and we see the legacy of that today with how alert() and prompt() will block many browser/user interactions when their message windows are open) - but because of widespread troll/joke webpage scripts in the very early 2000s which would spam popups and move windows around on the desktop and worse, browsers severely curtailed JavaScript's ability to interfere with user-interaction.