1

I would like to have the non-minified version of JavaScript libraries being used in development, and the minified versions used elsewhere.

How would I go about doing this if I'm using Rails assets?

I'm including like this:

application.haml

= javascript_include_tag :application

application.js

//= require jquery/jquery-1.7.2.min.js
//= require jquery/jquery-ui-1.8.20.custom.min.js
... and many more
2
  • the asset pipeline minifies after combining, so why do you need to add minimized version? Commented Jan 13, 2013 at 21:40
  • I did not know that--it doesn't happen in my project. Must be a disabled setting. Commented Jan 13, 2013 at 22:39

1 Answer 1

2

The better thing to do is use the :debug option

= javascript_include_tag "application", debug: Rails.env.development?

In debug mode, assets are not minified.

If you're actually maintaining 2 versions of each library (for example, a minified and raw version of jQuery), this is unnecessary. If you want to see the raw jQuery source in your browser's console, you should always use the unminified version of the library in combination with the :debug option above.

  • In development an unminified version of jQuery will be included in it's own <script> tag
  • in production jQuery will be minified and concatenated with all other assets in application.js in a single <script> tag.
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, it seems obvious now :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.