How to import jquery-ui properly

huhuhu picture huhuhu · Sep 15, 2014 · Viewed 21.1k times · Source

I can't get it to work and can't find any answers. Nothing is working for me.

Am I wrong by writing this into my header?

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>

my code is right, it's working in jfiddle but not outside of it.

Answer

Barmar picture Barmar · Sep 15, 2014

When you leave the scheme out of a URL, it uses the scheme from the page that contains the URL. So your <script> tag should work if the URL for the page is http:something or https:something; the reason for leaving out the scheme is so that it will use SSL if your page uses SSL, because browsers often complain if a secure page tries to load a non-secure script.

If you're trying to load jQuery from a local file instead of an HTTP page, you need to put the http: scheme into the jQuery URL explicitly.

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