I came across the same problem: there are many plugins that make too many assumptions and cause JavaScript errors on YOUR page, even when you are a good citizen; these errors have nothing to do with your plugin.
It makes no sense to try to handle errors in other plugins - IMO is better to be self-sufficient, but resistant to their errors.
In my case, errors stopped the DQLOM ready event, and my JavaScript initialization code did not execute. The exact form of the error is not important, although the solution is to simply fire several events.
The solution for me was to have backups, rather than relying on the JQuery DOM ready event:
- I wrapped any code that I wanted to run in the finished DOM event in my own function - for example. my_hardened_init_action ();
- I added the function my_hardened_init (), which runs only once. It calls my_hardened_init_action () on the first call and does nothing on subsequent calls.
- I have added various methods to call my_hardened_init () in the WordPress footer. In my case, I was only two. First try the regular jQuery DOM init, but back to the simple setTimeout (). Therefore, if the jQuery DOM init never fails due to JavaScript malfunctioning, the timeout fires shortly after the page has finished loading.
You can add several other backups - even add code to the header if necessary. Since my_hardened_init () is run only once, you can try as many times as you want to call it.
This worked on a bunch of client sites with a number of other broken plugins.
Hope this helps.
Jhong Dec 31 '13 at 7:10 2012-12-31 07:10
source share