# Dynamically linking to ajax.googleapis jquery

**URL:** <https://www.ruby-forum.com/t/dynamically-linking-to-ajax-googleapis-jquery/186580>\
**Category:** Rails\
**Created:** [April 9, 2010, 6:19am UTC](https://www.ruby-forum.com/t/dynamically-linking-to-ajax-googleapis-jquery/186580 "2010-04-09T06:19:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [April 9, 2010, 6:19am UTC](https://www.ruby-forum.com/t/dynamically-linking-to-ajax-googleapis-jquery/186580/1 "2010-04-09T06:19:54Z")

</div>

Hi  
I am using jquery and jqueryui in my application And in layout I use

\<%= javascript\_include\_tag  
“[http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js](http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js)”%\>  
\<%= javascript\_include\_tag  
“[http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js](http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js)” %\>  
\<%= stylesheet\_link\_tag  
“[http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css](http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css)”  
%\>

```
    My question is, there any problem by linking to css and js like

```

these. I am totally a newbie regarding this? Is this a performance issue  
in production. And I have one more concern(Dont know I am right) suppose  
if in any case those sights down then will it fail? What is the normal  
procedure for doing this? Whether I have to download all the sources to  
my application?

Thanks for your time  
Tom

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [April 9, 2010, 8:26am UTC](https://www.ruby-forum.com/t/dynamically-linking-to-ajax-googleapis-jquery/186580/2 "2010-04-09T08:26:07Z")

</div>

“Tom M.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote in message  
news:removed\_email\_address@domain.invalid…

> ```
> My question is, there any problem by linking to css and js like
> 
> ```
> 
> these. I am totally a newbie regarding this? Is this a performance issue  
> in production. And I have one more concern(Dont know I am right) suppose  
> if in any case those sights down then will it fail? What is the normal  
> procedure for doing this? Whether I have to download all the sources to  
> my application?

If Google is down (yes, it does happen on rare occasion!) the javascript  
files will fail to load. Any code that tries to use jquery would fail.  
In  
the best case, all remaining code will continue to work, and thus only  
some  
small part of the site will be broken. In the worst case, the browser  
will  
give up on running javascript for the page, and the page wil continue to  
work like javascript was not enabled. If your site is designed well it  
will  
work even when javascript is not enabled, but some non-essential fancy  
AJAX’y stuff might not work.

It is pretty easy to test out what would happen if they fail to load  
simply  
by changing the “/ajax/” part of each url to “/noajax/”, which of course  
does not exist and will cause the downloads to fail. Just be sure to  
change  
them back when done testing.

As for performance, remote loading from Google may sometimes be faster  
or  
other times slower than storing the file on the server. You can get more  
consistant perforance by putting the files on your server, but more  
consistant might not be better.

Many people err on the side of caution and choose to keep local copies  
of  
jquery.min.js, jquery-ui.min.js and jquery-ui.css on their servers. If  
in  
doubt, I’d suggest that. It is easy to download the files and place them  
in  
public/javascripts and public/stylesheets.

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [April 12, 2010, 5:52am UTC](https://www.ruby-forum.com/t/dynamically-linking-to-ajax-googleapis-jquery/186580/3 "2010-04-12T05:52:50Z")

</div>

Hi Joe

Thanks for your elaborate answer. It was useful

Tom
