treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Load local scripts. Why does this feel so ugly to me??

  • Howdy folks,

    Been away from the computer for LONG while now. Starting to get back in the grove and im helping a buddy out with one of his projects. Heres the deal:

    How i normally test and load jQuery

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script>window.jQuery || document.write(unescape("%3Cscript src='js/jquery-1.9.1.min.js'%3E%3C/script%3E"))</script>
    

    Well, i wanted to do the same thing for a the validation plugin but my result just feels so UGLY and I cant shake why. It works and isnt killing performance, i just feel that im doing it wrong.

    Test and local load jQuery Validate

    <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.0/jquery.validate.min.js"></script>
    <script>window.jQuery.fn.validate || document.write(unescape("%3Cscript src='js/jquery.validate-1.11.0.min.js'%3E%3C/script%3E"));</script>

    I will totally check out yalls feedback.

  • I would only check if jQuery is cached by browser. The validate fn probably wouldn't be, so I would just load it locally and not worry to much about it.

  • @AlenAbdula : Yeah, you're right. I'm pretty sure i'm over thinking things again lol. Thanks for the swift slap in face of truth...