Is the way JQuery is imported actually different in the real world


#1

I see that for these tutorials

<script type='text/javascript' src='script.js'></script> is used to import the JQuery script.

I am guessing that in the real world you would have this line for your JQuery script BUT would also need to import the JQuery library using something like

<script src="jquery-1.11.3.min.js"></script> (for HTML5)

I am learning django and so just was thinking ahead. I'm sure that linking javascript/JQuery up to my Django site will probably be less than strait forward though.


#2
<script src="jquery-1.11.3.min.js"></script>

assumes the library is present in the same resource folder as the current HTML document.

<script type='text/javascript' src='script.js'></script>

assumes the same location, but is not the jQuery library, though it may contain some jQuery code, which further assumes jQuery is present in memory. The two would load in this order, not the reverse.

The above can also be run offline given the local files. When online, we would normally load jQuery from a CDN since it is most convenient.

<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>

#3

I'm not learning Django, but once we get to live hosted pages, it has become customary to use schemeless URL's in our templates. Eg.

"//ajax.googleapi.com"

A single template may serve both the secure side of the site and the public side, and the protocols will be selected accordingly.


#4

@mtf Good posts! Re:

once we get to live hosted pages, it has become customary to use schemeless URL's in our templates.

though, it's actually become better to use https:// over // if HTTPS is available: https://www.paulirish.com/2010/the-protocol-relative-url


#5

Good to know. We could have predicted the schemeless approach would be short-lived.