Client-Side Javascript Error Logging – The Forgotten Child of Website Development


As an ASP.NET developer I incorporate server-side error logging in the mission critical projects I work on to track unhandled exceptions and more. In my server side .NET world ELMAH is the go-to solution. It’s an open source error logging solution that is super easy to configure and use. I can’t describe how beneficial it has been over the years.

Now let’s discuss the forgotten/hidden side of error logging. As the front-end of web sites has become more complex and relies more heavily on javascript, more errors are likely happening on the front end in the browser that developers don’t know about. They might have a solution in place for trapping errors on the server-side, but most developers I talk to don’t capture javascript errors generated in the client browser on production environments. Knowing that these errors are happening is critical. Most websites visitors won’t call you about a problem they see or find. You might lose a lead because something was broken on the form validation. You might lose a visitor after he/she gets frustrated because some piece of fancy UI isn’t working because of a javascript error.

We all must be careful to find the balance between helpful logging information and a drag on performance. I’ve tried a few different solutions over the years and they all have their pros and cons. Some are free and some are pay. Developers who make the effort can find what works best for them on Google. Another option is to write a custom logging system. I recently read that some folks are using Google Analytics to register an “Event” by modifying the “window.onerror” method. Interesting, but I haven’t personally tried that yet.

One strategy might be to implement a javascript logging solution for a designated period of time after a site launches to make sure everything is working as expected, then disable it to minimize performance impacts over the long-term. Another strategy might be to only log unhandled errors for the foreseeable future. I’ve always believed it’s important to continuously monitor the health of your website and client-side error logging is an important tool in that arsenal.

Share this post

The Author

Laura Hanssen

Senior Developer