[RAILS] About the asset pipeline

I'm not sure what the asset pipeline means, so I'll leave it to you.

The story in the first place

In the first place, the web browser displays the screen by reading `HTML, CSS, JavaScpirt, WebAssembly```. (WebAssembly is a new type of code that significantly improves performance) The mechanism that allows the browser to read `HTML, CSS, JavaScpirt, WebAssembly``` is called asset purpline.

What is an asset pipeline?

An asset pipeline is a framework for minimizing or compressing and concatenating JavaScript and CSS assets (such as minify: padding spaces and line breaks).

Your own summary A function that combines static files such as CSS and Javascript that are arranged so that humans can easily see them. Why put together → To reduce the number of requests to files and reduce processing.

Asset pipeline flow

  1. High-level language precompilation → Translate a language written for human understanding so that it can be understood by machines
  2. Concatenate → Combine multiple files into one
  3. Compress → Remove extra line breaks and margins to speed up reading
  4. Read the publicly placed file and display it on the browser

Implementation method

--In the development environment, there is nothing special to do because the mechanism that goes through the asset pipeline is automated. --In a production environment, you need to do it manually.

  1. (Execute the rails assets: precompile RAILS_ENV = production command)
  2. config.assets.compile = false in config / environments / production.rb Change false to true

Current question

Why set config.assets.compile = false to true? What is config.assets.compile in the first place?

Apparently config.assets.compile

Find and compile files when they don't exist

It seems that you can do it. (Rails document quote)

Description If "true", when the required file is not found in public / assets, the file is searched from app / assets etc. and compiled.

It seems convenient, but if you set it to true, it will put a load on the server ... Is it okay to set it to true and put a burden on using the mechanism of the asset pipeline to increase the processing speed? Once you come up with it, it won't stop!

So far, I have described what I have learned about the asset pipeline. I haven't understood the details yet, so I will study!

Reference article

https://railsdoc.com/page/config_assets_compile https://developer.mozilla.org/ja/docs/WebAssembly/Concepts https://www.transnet.ne.jp/2016/02/28/rails%E5%88%9D%E5%AD%A6%E8%80%85%E3%81%8C%E3%81%A4%E3%81%BE%E3%81%9A%E3%81%8Dcolnr%E3%80%8C%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E3%83%91%E3%82%A4%E3%83%97%E3%83%A9%E3%82%A4%E3%83%B3/

Recommended Posts

About the asset pipeline
Asset pipeline
About the method
About the package
Output about the method # 2
Commentary: About the interface
About the function double-java
About the ternary operator
About the length method
About the Kernel module
About the authenticate method.
About the map method
About the ancestors method
[Output] About the database
About the [ruby] operator
About the to_s method.
About specifying the JAXRS path
Output about the method Part 1
about the where method (rails)
A note about the scope
About the description of Docker-compose.yml
About the File :: Stat class
About the same and equivalent
About the Android life cycle
About the explanation about functional type
Rails Asset Pipeline Basic Key
About the programming language Crystal
Consideration about the times method
Error in production environment (The asset "~" is not present in the asset pipeline.)
About the behavior of ruby Hash # ==
About the language to be learned
About the basics of Android development
About the equals () and hashcode () methods
About the symbol <%%> in Rails erb
About the information sharing app band
About the current development environment (Java 8)
A murmur about the utility class
About the role of the initialize method
Think about the 7 rules of Optional
About =
Summary about the introduction of Device
About the log level of java.util.logging.Logger
"" Application.js "is not present in the asset pipeline" error in Ruby on Rails
Guess about the 2017 Java Persistence Framework (3) Reladomo
Check once again about the OpenSSL command
What is testing? ・ About the importance of testing
About the procedure for java to work
About the new Java release model @ Seki Java (2018/07/20)
About the operation of next () and nextLine ()
About the initial display of Spring Framework
About the error message Invalid redeclaration of'***'
About the treatment of BigDecimal (with reflection)
About the difference between irb and pry
[Japanese version Faker] About the gem "gimei"
About the number of threads of Completable Future
About the mechanism of the Web and HTTP