Search code examples
javascriptjquerysyntax-errortypeerroruncaught-exception

website that used to work suddenly throwing jquery "uncaught syntaxErrors"


I've helped a friend 3 years ago to develop a small website. It worked perfectly until some days ago. I've found by inspecting it, that it throws a bunch of jQuery syntax errors (also related to other jQuery plugins).

The errors displayed on the console are:

Uncaught SyntaxError: Unexpected token,                             jquery.colorbox-min.js:4
Uncaught SyntaxError: Unexpected number                         jquery.orbit-1.2.3.min.js:10
Uncaught SyntaxError: Unexpected identifier                               ddsmoothmenu.js:33
Uncaught SyntaxError: Unexpected identifier                     jquery.tipTip.minified.js:21
Uncaught TypeError: Property '$' of object [object Object] is not a function      (index):30

I as was saying, this was workin ok. I assume it has to do with the versions or the browser, but I'm not sure where to start.

Thanks in advance


Solution

  • I don't know who has been playing around with your files, but they seem to be corrupted.

    If you replace them with CDN/online versions:

    <!-- COLORBOX -->
    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.colorbox/1.4.3/jquery.colorbox-min.js" type="text/javascript"></script>
    
    <!-- ORBIT -->
    <script src="http://zurb.com/playground/uploads/upload/upload/208/jquery.orbit.min.js" type="text/javascript"></script>
    
    <!-- MENU -->
    <script type="text/javascript" src="http://www.dynamicdrive.com/dynamicindex1/ddsmoothmenu.js"></script>
    
    <!-- TOOLTIP -->
    <script type="text/javascript" src="http://cdn.jsdelivr.net/tiptip/1.3/jquery.tipTip.minified.js"></script>
    

    and take jQuery out of noConflict mode:

    //$.noConflict();
    

    Your site will work again.

    You can then make sure the versions are correct before downloading them once again and host them on your servers.