This may sound simple, but it's not :)

What I want, and most likely many theme developers do (themes that use javascript / jquery), is to warn the theme user that his site has javascript errors.

In my themes at least, in about 95% of these error situations, the problem comes from outdated / badly-written installed plugins. The other 5% comes from conflicts between up-to-date plugins and the theme. So my message would suggest the user to check his plugins one by one and fix the issues.

I found a solution for this, but only for the dashboard (in my theme settings). Essentially what I'm doing is loading the home page inside an iframe and wait 5 seconds for a function inside the iframe's document.ready() to send me the "OK" message. If it doesn't come, I display the error (I'm using postMessage to communicate with the iframe document).

Anyway, my question is how can I do this from the front page too? Without using pm, because it's too heavy (in the theme settings it's ok, because it's used for live design tweaks too)

Other unreliable solutions:

  • add the message just after <body>, and hide it with javascript (with js after the message); the problem is that errors might come up after the check
  • add the message anywhere in the HTML, and remove it with jQuery on document.ready; unacceptable because the user sees the message for 2-3 seconds, during which the site is loaded...
  • Why not only display it for current_user_can( 'manage_options' )?
    – kaiser
    Aug 8, 2011 at 23:58
  • Obviously that's what I would do in case I'd go with one of the above, but it's still an ugly solution. The admin would see a big red message for a few seconds on any page (s)he visits... Aug 9, 2011 at 1:12
  • 1
    How about adding a role of developer which gets the admin caps plus a special one to display dev stuff?
    – kaiser
    Aug 9, 2011 at 1:33

2 Answers 2


Why not just use the browser's "developer" tool to display the errors and the code that caused the error? I know for a fact that IE, Firefox and Safari each have developer tools available (I use them all the time) - I don't know about other browser's capabilities.


Just did a quick search to see if JavaScript has a global error handling function which you could use and found window.onerror. So I haven't looked any further into it to see if it's well supported, but presumably you could use the window.onerror function to send an ajax request to php which could send page,browser, probably failed script info etc. then use php to email the admin email this info. That way it could be triggered by any user viewing the site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.