Reputation: 1029
For example, I want to add datepicker
feature in my rails app. I have both options, that is, I can install bootstrap-datepicker
rails gem or download datepicker files and include in my project. Which is the better approach with respect to security and compilation/page load speed?
Upvotes: 3
Views: 101
Reputation: 652
Rails is all about following conventions and make life easier. The prefer way would be include a gem and require it in application.js
file. The other options would be including from a live CDN or download manually and include in the assets folder which does not seems to be a right choice.
Reasons:
If you download manually and include it in the assets folder, then in future if you ever need to upgrade to a latest version, you will need to repeat the process of downloading the file and include the assets folder.
If you include from a live CDN, this will make your layout
file(application.html.erb
) messy. You are going against assets
pipeline to minimise http requests which slower down the speed of
page rendering. Also you will have to repeat the same process of
updating URLs to upgrade to a latest version.
So its better to use gems and easy to change versions. You can change version of any library in the gem file.
Upvotes: 6