Ignore javascript syntax errors in a page and continue executing the script Ignore javascript syntax errors in a page and continue executing the script wordpress wordpress

Ignore javascript syntax errors in a page and continue executing the script


Try :

window.onerror = function(){   return true;}

That is if you can include this before the bugged script has been executed.


You should correct the old JavaScript error because it may create many problems, not for right now but for next time.

Put your JavaScript file / code at the top (before JS having error), and call it before JavaScript effected by other JavaScript code.

In case you need handle JavaScript exception at run time, best option is

try { /* run js code */ }     catch (error){ /* resolve the issue or bug */ }


You should be able to swallow any error using the error event:

$(window).error(function(e){    e.preventDefault();});

I've never attempted this, but it should work in theory.

It should be noted that this probably isn't a great solution to your problem. It could be that your plugin is interfering with other plugins. It is, of course, possible that the errors are no fault of your own, but generally speaking (with publicly released plugins) not the case.