Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I test potentially "browser-crashing" JavaScript?

I've been having a crack at some of the problems over at http://projecteuler.net/ with JavaScript. I've been using a simple html page and running my code in script tags so I can log my results in the browsers' console. When experimenting with loops I sometimes cause the browser to crash.

Is there a better environment for me to do this kind of development?

like image 396
Dr. Frankenstein Avatar asked Jun 10 '10 22:06

Dr. Frankenstein


People also ask

Why does Javascript keep crashing?

This usually happens when objects are added to an array but are not removed from that array when they are no longer in use. Over time, these objects build up until the process crashes due to memory overload.

Why does my Web browsers keep crashing?

Check for Malware Malware can cause your browser to crash randomly or when you visit certain websites. Some malware redirects your Internet searches or even takes complete control over your browser. Microsoft recommends that you use the Microsoft Security Scanner to search for malware on your computer.

Why are my tabs crashing?

A virus, trojan or malware, do a good scan. Running out of memory, consider adding more RAM. Too many Tabs open already, delete some. Running too many extensions, remove some.


2 Answers

  1. a browser that has separate processes for each tab
  2. debugger breakpoints
  3. an if that breaks the loop if some threshold for time is hit
like image 132
µBio Avatar answered Nov 09 '22 03:11

µBio


If you're running computationally expensive programs in your browser, you may want to look at using web workers. In short, they allow you to run code in a different thread which won't lock up the browser.

like image 34
nickf Avatar answered Nov 09 '22 04:11

nickf