I'm wondering if having many gems in the Gemfile are slowing down the site? Are they loaded when needed or are all loaded at every page request?
A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.
You use :require => false when you want the gem to be installed but not "required". So in the example you gave: gem 'whenever', :require => false when someone runs bundle install the whenever gem would be installed as with gem install whenever .
The Gemfile. lock allows you to specify the versions of the dependencies that your application needs in the Gemfile , while remembering all of the exact versions of third-party code that your application used when it last worked correctly. By specifying looser dependencies in your Gemfile (such as nokogiri ~> 1.4.
Your gemfile is a list of all gems that you want to include in the project. It is used with bundler (also a gem) to install, update, remove and otherwise manage your used gems. These gems belong to development environment and the test environment since they are for testing the application.
It really depends on what gems you are using (i.e. middleware vs. just some small library). However in the general case, more gems = more code to process = more time = slower site.
One tip that I can suggest to you is in your Gemfile, do something like this:
gem 'gemname', :require => false
To not have rails require this gem on startup. The downside of course is that you have to manually call require 'gemname'
whenever you want to use that gem. It's all a balance of performance vs. ease of use.
Bundler what is the require false on the gemfile means
I think that will answer your question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With