Search code examples
javascriptjquery

jQuery load problem -- for one person only


I have a page on my website that was visited 96 times. Only 1 page visit generated the JavaScript error "Uncaught TypeError: $ is not a function" which I understand means that the jQuery library didn't load properly. What I don't understand is:

(a) How could this problem happen to this person when it didn't to anyone else.
(b) What can I add to my code to detect the problem and handle it. Note that I store the useragent of each visit and the visitor in question had the same useragent as many other page visits that did not have the problem.


Solution

  • Instead of loading jQuery from an external server bundle it with your Javascript. That way either all of your JS will load (and include jquery) or none of it will load if there is an error while requesting the file.