Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery not working from Google CND

Tags:

jquery

cdn

I just started creating a html file and wanted to use jquery. When I use the jquery from my local machine like this, it works fine.

<script src="jquery.min.js"></script>

But when I try to use this, it does not work

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

I am not able to use any jquery functions when I load the script like this.

What am I doing wrong here?

EDIT: Btw, my html file is on the local machine in drive C:/

like image 387
Joe Slater Avatar asked Mar 07 '13 18:03

Joe Slater


People also ask

How can we ensure jQuery loads even if the CDN is down?

Note: Use the full path to your downloaded jQuery file. In my case, both HTML and jQuery file is in the same folder. Now, we will see how to load local jQuery in case our CDN fails. Write the following lines of code, and it will add jQuery from the machine when CDN fails.

What is Google CDN jQuery?

Projects In JavaScript & JQueryGoogle provides CDN support for jQuery via the googleapis.com domain. The latest version of Google CDN provides four different types of jQuery versions- normal (uncompressed), minified, slim, and slim & minified. Google CDN provides the jQuery via ajax.googleapis.com domain.

Should I use CDN for jQuery?

There are a lot of people that say you should always use a CDN for libraries like jQuery (and other popular projects, as well). They say this for good reason. Using a CDN, as noted already, can reduce latency and allow browsers to cache a common file so it doesn't even have to load it from a server.

What is the best CDN for jQuery?

If you don't need HTTPS support, the fastest CDN is actually the official jQuery CDN, provided by Media Temple. Google's Libraries API CDN is a good second choice after that. If you need support for HTTPS, your best option is Google's Libraries API CDN.


1 Answers

Your url is incomplete. I believe they leave off the http to show that you can use either http or https, because if you're on a server you don't need it. You only need to add it in if you're running off your file system.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
like image 142
Jack Avatar answered Oct 11 '22 12:10

Jack