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

Aakash Chakravarthy picture Aakash Chakravarthy · Aug 31, 2012 · Viewed 42k times · Source

I develop plugins for WordPress. It uses some jquery in the user side (themes) as a jquery plugin. The problem is, when there is an javascript error with other plugins made by other autors, my plugin's javascript fails to execute.

And the worst thing is people consider that there is a serious fault with my plugin even though it works 100% fine with error handling conditional statements. But it is actually due to some other javascript syntax errors of some other WP plugin/theme authors.

Is there a way to continue execute my plugin JS ignoring other JS errors. Or can i have suggestions to handle this problem ??

enter image description here

Answer

Cosmin picture Cosmin · Sep 17, 2012

Try :

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

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