In an app I'm debugging, a previous developer appears to be relying on underscore.js to do a couple things.
I keep intermittently getting "_ is undefined" errors in my browser console, preventing chunks of the app from running correctly.
The underscore library eventually appears to load, since I'm able to do console.log(_)
in my browser and get a giant object as a result, once the page has fully loaded.
My question is this: Is there a preferred way to wrap functions that rely on underscore? (In other words, do underscore developers often use something similar to the old practice of wrapping a bunch of logic inside $(function(){...})
in order to make sure that it runs after jQuery is loaded?)