13/14 Outside CodeAcademy


#1

I was having problems getting the accordion to work from the Break Out Your .accordion()!" section.
Eventually I learned I needed to change

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>

to one of these

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>

or

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>

Also, I needed to include jQuery by adding

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

I found a place where inserting this line works, but does it matter where I add this? In other words, does it need to be before or after other links, scripts, etc.?

Also, does it matter which version of jQuery to add?
I also tried using jQuery 1.11.3 instead of 1.9.1 by using this line instead.

It worked, but I have no idea how to figure out which versions I truly need to use.


#2

Hey Ca4python,

The reason for that is because // uses protocol relative URLs. So, if the page you're on is HTTPS, the file will load as HTTPS too. Same for HTTP, and any other protocol there is. When viewing the file locally, you're using the file protocol, which means the browser is trying to fetch file://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js, which doesn't work, since file is for local stuff only.
Make sense? :slightly_smiling:

Yes; The order of your <script> tags should be:

  1. jQuery
  2. jQuery UI
  3. Your own files

While you're doing basic stuff, it doesn't really matter, so use the latest version. jQuery is unlikely to change any of it's basic features anytime soon, AFAIK. Once you're doing advanced stuff though, it gets a little harder to decide. I'd say probably still the latest version, but then make sure your code works with the next version before upgrading, maybe.


#3

Yes, the HTTPS vs file protocol makes sense.
Regarding the script tags, I'll take your word. Also, I think at least one of the jQuery CodeAcademy lessons put the script.js file before the jQuery UI file. It would be nice to have the lessons match the recommended/preferred order.
Thanks.