# How to use local javascript library for development and externally hosted for production?

**URL:** <https://www.ruby-forum.com/t/how-to-use-local-javascript-library-for-development-and-externally-hosted-for-production/193409>\
**Category:** Rails\
**Created:** [August 17, 2010, 10:51am UTC](https://www.ruby-forum.com/t/how-to-use-local-javascript-library-for-development-and-externally-hosted-for-production/193409 "2010-08-17T10:51:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lexer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a8b319/32.png) [@lexer](https://www.ruby-forum.com/u/lexer)\
**Post date:** [August 17, 2010, 10:51am UTC](https://www.ruby-forum.com/t/how-to-use-local-javascript-library-for-development-and-externally-hosted-for-production/193409/1 "2010-08-17T10:51:55Z")

</div>

Hi guys,

I want to set up my RoR project to use local javascript library for  
development and externally hosted for production (for example jquery  
from google). How it could be achieved?

Regards,  
Alexey Zakharov

---

<div class="post-metadata">

**Author:** ![lexer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a8b319/32.png) [@lexer](https://www.ruby-forum.com/u/lexer)\
**Post date:** [August 17, 2010, 11:07am UTC](https://www.ruby-forum.com/t/how-to-use-local-javascript-library-for-development-and-externally-hosted-for-production/193409/2 "2010-08-17T11:07:43Z")

</div>

On 17 Aug 2010, at 07:07, lexer wrote:

> I want to set up my RoR project to use local javascript library for  
> development and externally hosted for production (for example jquery  
> from google). How it could be achieved?

\<% if RAILS\_ENV=“production”\>  
javascript\_include\_tag  
"[http://somewhere.com/javascript\_file\_without\_js](http://somewhere.com/javascript_file_without_js)  
"  
\<% else %\>  
javascript\_include\_tag “javascript\_file\_without\_js”  
\<% end %\>

> **[ActionView::Helpers::AssetTagHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#M002225)**
>
> This module provides methods for generating HTML that links views to assets such as images, JavaScripts, stylesheets, and feeds.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![lexer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a8b319/32.png) [@lexer](https://www.ruby-forum.com/u/lexer)\
**Post date:** [August 17, 2010, 11:08am UTC](https://www.ruby-forum.com/t/how-to-use-local-javascript-library-for-development-and-externally-hosted-for-production/193409/3 "2010-08-17T11:08:54Z")

</div>

On 17 Aug 2010, at 11:05, Peter De Berdt wrote:

> \<% if RAILS\_ENV=“production”\>

Typo: \<% if RAILS\_ENV==“production”\>

---

<div class="post-metadata">

**Author:** ![lexer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a8b319/32.png) [@lexer](https://www.ruby-forum.com/u/lexer)\
**Post date:** [August 17, 2010, 3:38pm UTC](https://www.ruby-forum.com/t/how-to-use-local-javascript-library-for-development-and-externally-hosted-for-production/193409/4 "2010-08-17T15:38:50Z")

</div>

Another option is to create your own configuration file and use the  
URL to the JavaScript file as a configuration variable.

See here: [#85 YAML Configuration File - RailsCasts](http://railscasts.com/episodes/85-yaml-configuration-file)

---

<div class="post-metadata">

**Author:** ![lexer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a8b319/32.png) [@lexer](https://www.ruby-forum.com/u/lexer)\
**Post date:** [August 18, 2010, 4:52am UTC](https://www.ruby-forum.com/t/how-to-use-local-javascript-library-for-development-and-externally-hosted-for-production/193409/5 "2010-08-18T04:52:17Z")

</div>

Thanks guys. That was really helpful!

---

<div class="post-metadata">

**Author:** ![lexer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a8b319/32.png) [@lexer](https://www.ruby-forum.com/u/lexer)\
**Post date:** [August 17, 2010, 11:11am UTC](https://www.ruby-forum.com/t/how-to-use-local-javascript-library-for-development-and-externally-hosted-for-production/193409/6 "2010-08-17T11:11:14Z")

</div>

On 17 August 2010 10:07, Peter De Berdt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On 17 Aug 2010, at 11:05, Peter De Berdt wrote:
> 
> > \<% if RAILS\_ENV=“production”\>
> 
> Typo: \<% if RAILS\_ENV==“production”\>

As an aside, the RAILS\_ENV constant is now deprecated; the new way to  
do this test is:

if Rails.env.production?

Chris
