javascript_include_tag在Rails 4.1中开发需要44秒

时间:2014-10-06 06:43:01

标签: performance ruby-on-rails-4 upgrade sprockets

我正在使用Rubinius 2.2.10和Rails 4.1.6。

自从rails 3.2升级后,每当javascript发生变化时,我的开发环境需要花费很长时间才能加载sprockets的javascript_include_tag。 44秒(我正在使用sprockets-2.11.0)

在我的development.rb中有这个选项:

# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true

但即使我将其设置为false也需要相同的时间。

应用程序(bootstrap和datatables)中有相当多的javascript,但它在Rails 3.2上从未花费那么长时间。任何想法为什么会发生这种情况以及如何加快速度?

这是我的完整development.rb文件 -

require File.expand_path(File.join(File.dirname(__FILE__), 'environments_module.rb'))
include EnvironmentsModule

Rails.application.configure do #- Registration::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  APP_CONFIG= YAML.load_file(File.join(Rails.root, "config", "calm_app.yml"))

  config.communication_host_url = "http://localhost:3004"

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Log error messages when you accidentally call methods on nil.
  config.whiny_nils = true

  # Do not eager load code on boot.
  config.eager_load = false


  # Show full error reports and disable caching
  config.consider_all_requests_local       = true

  #CACHING
  # config.cache_store = :memory_store, { size: 64.megabytes }
  config.cache_store = :mem_cache_store, {:pool_size => 5, :compress => true}
  #not specifying a server above, this means memcache server is running on localhost on default port - this may not be ideal see the rails guide
  config.action_controller.perform_caching = true

  ##  # Don't care if the mailer can't send
  config.action_mailer.raise_delivery_errors = false
  config.action_mailer.default_url_options =  APP_CONFIG['invitation_mailer']['default_url_options']
  config.action_mailer.perform_deliveries = true
  config.action_mailer.delivery_method = :sendmail

  # Print deprecation notices to the Rails logger
  config.active_support.deprecation = :log

  config.active_record.migration_error = :page_load

  #log ActiveRecord
  ActiveRecord::Base.logger = Logger.new(STDOUT) if defined? Rails::Console

  config.assets.js_compressor = Uglifier.new(mangle: false) # default is `true` in Rails
  config.assets.debug = true
  config.assets.raise_runtime_errors = true

  config.middleware.use ExceptionNotification::Rack,
    :email => {
        :email_prefix => "[Exception]",
        :sender_address => %{support@test.com},
        :exception_recipients => %w{calm@test, calmernst@test.com, rya@test.com}
    }

  # auto rotate log files, keep 2 of 3MB each
  config.logger = Logger.new(config.paths['log'].first, 1, 3*1024*1024)
  config.log_level = :debug #:info
  #this is the config for the bullet gem which helps to identify inefficient queries in development
  config.after_initialize do
    Bullet.enable = true
    Bullet.bullet_logger = true # see results in log/bullet.log
  end

end

1 个答案:

答案 0 :(得分:1)

通过删除

来解决此问题
config.assets.js_compressor = Uglifier.new(mangle: false) # default is `true` in Rails

来自config / environments / development.rb

我只需要将其用于生产,因此没有理由将其用于开发.rb。