My rails app generates an html page that includes about 40 links and 80 scripts in the head. This can't be normal, can it? I wonder if I can reduce those, if it might help with the memory errors that my app is throwing on heroku. Or if it can help my app's performance speed.
Compiled html (I'll only include the first four link tags and the first four script tags, unless I get a request to post them all.)
<html>
<head>
<title>Dr. Macejkovic | Mr. Z School </title>
<link rel="stylesheet" media="all" href="/assets/jquery-ui/theme.self-830c3407ba1359ea36eee978235be14de5b78dacfa658a31226fe4f2b0faa7e7.css?body=1" data-turbolinks-track="true" />
<link rel="stylesheet" media="all" href="/assets/jquery-ui/core.self-e4bdefd3813c8a715955a6c65b9e730846dcae6a0576618563d635ff0b18a3ca.css?body=1" data-turbolinks-track="true" />
<link rel="stylesheet" media="all" href="/assets/jquery-ui/accordion.self-aa0730fc025317fed4feff2aa5fc07cba5a545dfc5c913a2984ba6f8695b29fb.css?body=1" data-turbolinks-track="true" />
<link rel="stylesheet" media="all" href="/assets/jquery-ui/autocomplete.self-f0b810a4a7bb8c90994675d7c5bfe636d615a5785cf81cae3340aa5e6adc55ca.css?body=1" data-turbolinks-track="true" />
#40 additional similar link tags omitted
<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="lQ2XTs3tTFNf+nuVR2NS9FPk/R4JWOO75SVBJuxfok547SCaN2KooB44hVwjJo1Pl5oX+bahrG8OdUyow5u6eQ==" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/r29/html5.min.js">
</script>
<![endif]-->
<script src="/assets/jquery.self-660adc51e0224b731d29f575a6f1ec167ba08ad06ed5deca4f1e8654c135bf4c.js?body=1" data-turbolinks-track="true"></script>
<script src="/assets/jquery_ujs.self-e87806d0cf4489aeb1bb7288016024e8de67fd18db693fe026fe3907581e53cd.js?body=1" data-turbolinks-track="true"></script>
<script src="/assets/bootstrap.self-d0e973a52d36a01036265aeefaf2d1ae3499d2cb231a9be3bd846432daf231de.js?body=1" data-turbolinks-track="true"></script>
<script src="/assets/jquery.turbolinks.self-176b9819f30444d441e820bbccd3264fe57753aeafd54dec732b0dbc77129a2a.js?body=1" data-turbolinks-track="true"></script>
#80 additional similar script tags omitted
</head>
Gemfile
source 'https://rubygems.org'
gem 'rails', '5.0.0'
gem 'bcrypt', '3.1.11'
gem 'faker', '1.6.3'
gem 'will_paginate', '3.1.0'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass', '3.3.6'
gem 'puma', '3.4.0'
gem 'sass-rails', '5.0.5'
gem 'uglifier', '3.0.0'
gem 'coffee-rails', '4.2.1'
gem 'jquery-rails', '4.1.1'
gem 'jquery-ui-rails'
gem 'turbolinks', '5.0.0'
gem 'jquery-turbolinks'
gem 'jbuilder', '2.4.1'
gem 'best_in_place', '~> 3.1'
gem 'responders', '~> 2.2'
gem 'carrierwave', '0.11.2'
gem 'mini_magick', '~> 4.3'
gem 'figaro'
gem 'fog-aws', '0.12.0'
group :development, :test do
gem 'sqlite3', '1.3.11'
gem 'byebug', '9.0.0', platform: :mri
end
group :development do
gem 'web-console', '3.1.1'
gem 'listen', '3.0.8'
gem 'spring', '1.7.1'
gem 'spring-watcher-listen', '2.0.0'
end
group :test do
gem 'rails-controller-testing', '0.1.1'
gem 'minitest-reporters', '1.1.9'
gem 'guard', '2.13.0'
gem 'guard-minitest', '2.4.4'
gem 'capybara'
gem 'poltergeist', '~> 1.10'
gem 'database_cleaner'
end
group :production do
gem 'pg', '0.18.4'
end
App/views/layouts/application.html.erb
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %> </title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
<% flash.each do |message_type, message| %>
<%= content_tag(:div, message, class: "alert alert-#{message_type}") %>
<% end %>
<%= yield %>
<%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %>
</div>
</body>
</html>
Thank you in advance for any insight.
PS This question is only one of the steps that I'm trying in my quest to resolve the memory errors. If you have some clear advice or some recommended articles, I would be grateful for those too. I'm working my way through this article http://www.schneems.com/2015/05/11/how-ruby-uses-memory.html , but I'm struggling to figure out how to apply this info to my app.
The above additional js files loading through the gems
gem 'jquery-rails', '4.1.1'
gem 'jquery-ui-rails'
gem 'turbolinks', '5.0.0'
gem 'jquery-turbolinks'
When you have included those gems in gem file, the js files will be added to the
app/assets/javascripts/application.js
For example:
//= require jquery
//= require jquery_ujs
If you don't need those jquery and turbo links you can take an action on those gems.
For more information you can see those gems documentation.
for jquery: https://www.rubydoc.info/gems/jquery-rails/4.3.3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.