We have a webpart that relies heavily on jQuery to grab data from our SharePoint lists and render them on a page. This webpart includes links to three additional libraries that contain functions and code that are called within the webpart.
I am noticing some odd behavior when it comes to jQuery firing within our SharePoint page. In some instances, jQuery loads just fine and the page renders correctly. Other times, the page errors out and it appears that code is being executed out-of-order, as the browser console tells me that certain functions are not valid.
As a simple test, I added this code to the page:
$( document ).ready(function() {
alert('Hello World!');
});
Upon reloading the page, periodically I receive this error:
Uncaught ReferenceError: $ is not defined - which leads me to believe that jQuery isn't loading correctly.
Other times, the page loads and alert fires, however, I receive errors like this:
$(...).prettyPhoto is not a function - but I can see that our prettyPhoto library has loaded.
Any thoughts or suggestions on where to start looking?