Added conditional to fix JS console warnings.

Without this fix, the library was throwing an undefined error on the
'ready' event, and it affected the minified version too.