Git Product home page Git Product logo

Comments (8)

indirect avatar indirect commented on August 23, 2024

Use :defaults, which is automatically adjusted to include only the correct file.

from jquery-rails.

gtd avatar gtd commented on August 23, 2024

So the jquery-rails position is that :all is not a supported option?

from jquery-rails.

indirect avatar indirect commented on August 23, 2024

The jquery-rails position is that if you use :all, you're going to get all of the files.

from jquery-rails.

gtd avatar gtd commented on August 23, 2024

Well, let me put it this way, if you're using :all, which is quite common, with jquery-rails, which is the Rails 3.1 default, you're going to get 250KB of unminified duplicate jquery in the middle of your production javascript cache *in addition to the 30KB minified version at the top. At the very very least you need a strong warning in the docs about that.

from jquery-rails.

indirect avatar indirect commented on August 23, 2024

The Rails docs explicitly state "if you need to extend the default JavaScript set for any reason (e.g., you’re going to be using a certain .js file in every action), then take a look at the register_javascript_include_default method.". That method says that you should simply modify config.action_view.javascript_expansions[:defaults]. I usually change it in application.rb, like this:

config.action_view.javascript_expansions[:defaults] += %w(extra.js files.js here.js)

So the Rails docs already cover this, and the jquery-rails docs already explicitly state that :defaults is managed by the plugin. That said, if you want to send a pull request clarifying this in the readme, I will take it. Thanks.

from jquery-rails.

gtd avatar gtd commented on August 23, 2024

Come on man, I don't need a Rails lesson. This is not a defaults issue. The interaction of :defaults and :all is very well-defined and useful. You put defaults at the top where order is dependent and as prerequisites for other files. :all is a catch-all that gets the rest of the files. It automatically skips over the already-included defaults. The problem is that it doesn't see the minified jqueries as duplicates.

If I want to implement your solution for my project with 60 javascript files I can either list them all, or else I can duplicate a bunch of code from the private expand_javascript_sources and collect_asset_files methods in ActionView::Helpers::AssetTagHelper. Neither one is a great solution.

Why don't you think javascript_include_tag :all needs to work with jquery-rails?

from jquery-rails.

indirect avatar indirect commented on August 23, 2024

Jquery-rails is part of the new asset pipeline strategy in Rails 3.1. As such, it is designed to bundle all your java scripts into a single minified file. If you want to do something else, you're welcome to, but that's not the convention that rails 3.1 and jquery-rails are designed to support.

Furthermore, not even possible for jquery-rails to change how :all works without monkeypatching rails itself. If you want to change the semantics of :all, or make it configurable, I suggest you talk to the rails team instead.

On Jul 17, 2011, at 10:21 AM, dasil003 [email protected] wrote:

Come on man, I don't need a Rails lesson. This is not a defaults issue. The interaction of :defaults and :all is very well-defined and useful. You put defaults at the top where order is dependent and as prerequisites for other files. :all is a catch-all that gets the rest of the files. It automatically skips over the already-included defaults. The problem is that it doesn't see the minified jqueries as duplicates.

If I want to implement your solution for my project with 60 javascript files I can either list them all, or else I can duplicate a bunch of code from the private expand_javascript_sources and collect_asset_files methods in ActionView::Helpers::AssetTagHelper. Neither one is a great solution.

Why don't you think javascript_include_tag :all needs to work with jquery-rails?

Reply to this email directly or view it on GitHub:
#15 (comment)

from jquery-rails.

gtd avatar gtd commented on August 23, 2024

Where on earth did you get the impression that I was suggesting that Rails needs to change its behavior? To the contrary, I specifically said that I like the :all functionality and wish I could use it with jquery-rails, however because it's bloating up my cached js I can not.

I'm not saying there's an obvious answer here, but I'm disappointed that you don't seem to think it's an issue worthy of consideration. There are ways to mitigate the negative effects here, like allowing the operation of the jquery-rails gem with a single version of jquery, something which currently will just break the app in either dev or production, but since you seem to think that it's a non-issue I'm more inclined to fork and forget than to actually put any more effort into a proper solution.

One thing I can tell you for sure though, when people who are using :all realize that their cached js file suddenly has a duplicate copy of jquery sandwiched in the middle you're going to have a lot more of these issues to close.

from jquery-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.