-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🧹 Clean up jquery rails #4034
base: master
Are you sure you want to change the base?
🧹 Clean up jquery rails #4034
Conversation
09ff0fd
to
cbe979d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't compile assets:
Sprockets::FileNotFound: couldn't find file 'vendor/jquery-1.11.3.min.js' with type 'application/javascript'
cbe979d
to
a2dc400
Compare
@@ -238,7 +238,7 @@ def self.replace_googleapis(url) | |||
return url unless Rails.env.test? | |||
|
|||
if url =~ %r{//ajax.googleapis.com/ajax/libs/jquery/(.+?)/jquery.min.js} | |||
"vendor/jquery-#{$1}.min.js" | |||
"essential_assets/jquery-#{$1}.min.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG, why did we have googleapis in the first place??!
Looks like there is still some leftover:
<script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" type="text/javascript"></script> |
I think in the next PR we'd need to remove both this helper, and that external JS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works apparently fine for me 👍
TL;DR
UPDATE: It was not so simple!
Description
Forms and other asynchronous stuff is managed by
rails-ujs
(Unobtrusive scripting adapter for jQuery).It is embedded in the jQuery imported as gem
jquery-rails
as following:In recent rails (5+), rails-ujs is included in the gem rails and it's imported like this:
Moreover
rails-jquery
includes jquery 1, 2 and 3:Therefore, the best way to unify jquery 1 is to remove all other from assets/vendor and just use the one provided by this gem.
Webpack packages will still use jQuery 3.x from node_modules and there's even a node module for rails-ujs... so in time we'll see wether we stick to Gem of NPM.