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

前端 未结 11 909
日久生厌
日久生厌 2020-12-02 18:21

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

11条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 18:58

    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 */ }
    

提交回复
热议问题