Comments (8)
Use :defaults, which is automatically adjusted to include only the correct file.
from jquery-rails.
So the jquery-rails position is that :all is not a supported option?
from jquery-rails.
The jquery-rails position is that if you use :all, you're going to get all of the files.
from jquery-rails.
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.
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.
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.
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
andcollect_asset_files
methods inActionView::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.
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)
- url.indexOf is not a function in jQuery.fn.load = function( url, params, callback ) HOT 1
- CVE-2019-5428 HOT 1
- Security issue with jquery 3.4.1 HOT 7
- Issue a security advisory for versions < 4.4.0 HOT 5
- jQuery not loading HOT 3
- jquery-rails with Spockets 4 JS HOT 1
- Dropping `git` in gemspec & using Packaging extension HOT 1
- Update jQuery to v3.6.0 HOT 4
- The Jquery V3.5.0+ already removed trim method.
- Update `jquery-rails` to include new jquery-ujs for better Turbo compatibility HOT 1
- JQuery 3.6.1 released HOT 1
- Rails 7 with importmap HOT 3
- What is the status of v4.5.1 ? HOT 1
- jquery-rails doesn't work correctly in Rails 7 HOT 2
- Drop support for jQuery 1 & 2
- allert does not work HOT 1
- Update jQuery to v3.6.4 HOT 1
- JQuery 3.7.0 released HOT 7
- JQMIGRATE: jQuery.fn.submit() event shorthand is deprecated HOT 1
- jQuery 3.7.1 released HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-rails.