Search code examples
javascripthtmlcssgoogle-chromewebkit

Web Game has many errors: does this matter?


Recently I finished (or almost finished) coding a core concept of a web game that I'm still working on. However, when I run the code in Chrome (the game is meant for Webkit browsers only), I get a LOT of errors. But, they do not affect what the code is trying to achieve. The code is written in JavaScript/HTML/CSS.

To get into more detail, my code is part of a "Battle" sequence and is looped each turn. Each loop however produces hundreds of errors (I assume it can even produce 1000's each loop), with each successive loop producing more errors than the previous one. Depending on the number of turns the battle takes, the page may be spitting out thousands and thousands of errors each loop... not good. The errors are literally all "Cannot set property "className" of undefined" (my code uses a bunch of these to change the animations of some sprites I'm using). The good thing though, as mentioned above, is that these errors do not seem to be affecting the overall battle itself, ie the battle can progress smoothly.

So my question is this: Will the enormous amount of errors pose any kind of problem, for example to the browser or web page performance? I also plan to transfer this game onto Android and will be using WebView in Android Studio. Will the errors be any problem there either? Obviously I will try and fix this up, but if it isn't a big issue I will leave it for later and start working on other parts of the game.

Thank you for reading my question, and if it's confusing I will try to explain more.

Cheers.


Solution

  • Good news guys, I fixed my code and now I am getting no errors! All I did was add an if statement that checks if the element exists on the page, and if it doesn't the code doesn't run which in turn doesn't give an error.