SlideShare ist ein Scribd-Unternehmen logo
1 von 10
Rails Asset Pipeline




     Nathan Broadbent
        Onboard Coding Ltd.


https://twitter.com/ndbroadbent
http://github.com/ndbroadbent
Sprockets
●   Packages and minifies your JavaScript and
    CSS assets
●   Dependency management
●   Pre-processor pipeline
    –   CoffeeScript
    –   SCSS / LESS
    –   Minification
Sprockets Directives
●   //= require example_asset
    –   searches app/assets/, vendor/assets, lib/assets,
        <gem>/app/assets
    –   will find:
         ● example_asset.js
         ● example_asset.js.coffee


         ● example_asset.js.coffee.erb


●   //= require_tree .
    –   recursively requires all assets in the current directory,
        including subdirectories
Gems to improve
the asset pipeline
turbo-sprockets-rails3
●   Speeds up rake assets:precompile by only
    recompiling changed assets, based on a hash
    of their source files
●   Only compiles once to generate both
    fingerprinted and non-fingerprinted assets
turbo-sprockets-rails3
    Benchmark on a small Rails app:

●   Uninstalled: 26.993s
●   Installed
    –   first run: 18.525s
    –   unchanged assets: 9.386s
quiet_assets
●   Hide asset requests in your Rails logs.
●   Lets you focus on SQL queries and rendering
●   Just add gem 'quiet_assets' to Gemfile
assets_precompile_enforcer
●   Raises an exception if an asset is not found in
    config.assets.precompile
●   Avoid 500 errors in production due to
    uncompiled assets
Assets in Rails 4
●   Much faster, don't need turbo-sprockets-rails3
●   Non-digest assets are no longer compiled if
    fingerprints enabled
●   Source maps support: Easily debug errors in
    minified javascript
    –   http://www.html5rocks.com/en/tutorials/developert
        ools/sourcemaps/
    –   If you give your asset source maps to Errbit, it
        could show you where a production error occurred
        in the original (unminified) JavaScript
Questions or
Comments?

Weitere ähnliche Inhalte

Was ist angesagt?

oracle rac training | oracle rac training videos | oracle rac dba training
oracle rac training |  oracle rac training videos |  oracle rac dba trainingoracle rac training |  oracle rac training videos |  oracle rac dba training
oracle rac training | oracle rac training videos | oracle rac dba training
Nancy Thomas
 
NoSQL Database in .NET Apps
NoSQL Database in .NET AppsNoSQL Database in .NET Apps
NoSQL Database in .NET Apps
Shiju Varghese
 

Was ist angesagt? (20)

WebAPI::DBIC - Automated RESTful API's
WebAPI::DBIC - Automated RESTful API'sWebAPI::DBIC - Automated RESTful API's
WebAPI::DBIC - Automated RESTful API's
 
Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012
 
Using ansible to manage cloud stack
Using ansible to manage cloud stackUsing ansible to manage cloud stack
Using ansible to manage cloud stack
 
A production project's architecture with clojure
A production project's architecture with clojureA production project's architecture with clojure
A production project's architecture with clojure
 
Data Pipelines with Apache Airflow
Data Pipelines with Apache AirflowData Pipelines with Apache Airflow
Data Pipelines with Apache Airflow
 
Hadoop course content Syed Academy
Hadoop course content Syed AcademyHadoop course content Syed Academy
Hadoop course content Syed Academy
 
HBaseCon2017 Community-Driven Graphs with JanusGraph
HBaseCon2017 Community-Driven Graphs with JanusGraphHBaseCon2017 Community-Driven Graphs with JanusGraph
HBaseCon2017 Community-Driven Graphs with JanusGraph
 
URLs in Joomla - How to get it right
URLs in Joomla - How to get it rightURLs in Joomla - How to get it right
URLs in Joomla - How to get it right
 
Ruby w/o Rails (Олександр Сімонов)
Ruby w/o Rails (Олександр Сімонов)Ruby w/o Rails (Олександр Сімонов)
Ruby w/o Rails (Олександр Сімонов)
 
Groovygrails
GroovygrailsGroovygrails
Groovygrails
 
Dynamic Class-Based Spark Workload Scheduling and Resource Using YARN with L...
 Dynamic Class-Based Spark Workload Scheduling and Resource Using YARN with L... Dynamic Class-Based Spark Workload Scheduling and Resource Using YARN with L...
Dynamic Class-Based Spark Workload Scheduling and Resource Using YARN with L...
 
oracle rac training | oracle rac training videos | oracle rac dba training
oracle rac training |  oracle rac training videos |  oracle rac dba trainingoracle rac training |  oracle rac training videos |  oracle rac dba training
oracle rac training | oracle rac training videos | oracle rac dba training
 
Intro to sbt-web
Intro to sbt-webIntro to sbt-web
Intro to sbt-web
 
Apache Airflow
Apache AirflowApache Airflow
Apache Airflow
 
GraphQL API on a Serverless Environment
GraphQL API on a Serverless EnvironmentGraphQL API on a Serverless Environment
GraphQL API on a Serverless Environment
 
Caching By Nyros Developer
Caching By Nyros DeveloperCaching By Nyros Developer
Caching By Nyros Developer
 
Apache airflow
Apache airflowApache airflow
Apache airflow
 
Introduction to apache spark
Introduction to apache sparkIntroduction to apache spark
Introduction to apache spark
 
Operation Migration: Migrating Static Content into Cascade Server with our ne...
Operation Migration: Migrating Static Content into Cascade Server with our ne...Operation Migration: Migrating Static Content into Cascade Server with our ne...
Operation Migration: Migrating Static Content into Cascade Server with our ne...
 
NoSQL Database in .NET Apps
NoSQL Database in .NET AppsNoSQL Database in .NET Apps
NoSQL Database in .NET Apps
 

Ähnlich wie Rails 3 Asset Pipeline

Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructure
harendra_pathak
 

Ähnlich wie Rails 3 Asset Pipeline (20)

Asset Pipeline in Ruby on Rails
Asset Pipeline in Ruby on RailsAsset Pipeline in Ruby on Rails
Asset Pipeline in Ruby on Rails
 
Understanding asset pipeline plugin
Understanding asset pipeline pluginUnderstanding asset pipeline plugin
Understanding asset pipeline plugin
 
AngularJS meets Rails
AngularJS meets RailsAngularJS meets Rails
AngularJS meets Rails
 
Apache Spark - A High Level overview
Apache Spark - A High Level overviewApache Spark - A High Level overview
Apache Spark - A High Level overview
 
Rails - getting started
Rails - getting startedRails - getting started
Rails - getting started
 
AWS (Hadoop) Meetup 30.04.09
AWS (Hadoop) Meetup 30.04.09AWS (Hadoop) Meetup 30.04.09
AWS (Hadoop) Meetup 30.04.09
 
Monitor Apache Spark 3 on Kubernetes using Metrics and Plugins
Monitor Apache Spark 3 on Kubernetes using Metrics and PluginsMonitor Apache Spark 3 on Kubernetes using Metrics and Plugins
Monitor Apache Spark 3 on Kubernetes using Metrics and Plugins
 
Boost your productivity with Scala tooling!
Boost your productivity  with Scala tooling!Boost your productivity  with Scala tooling!
Boost your productivity with Scala tooling!
 
Os riak1-pdf
Os riak1-pdfOs riak1-pdf
Os riak1-pdf
 
Intro to sbt-web
Intro to sbt-webIntro to sbt-web
Intro to sbt-web
 
Real time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache SparkReal time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache Spark
 
Spark Saturday: Spark SQL & DataFrame Workshop with Apache Spark 2.3
Spark Saturday: Spark SQL & DataFrame Workshop with Apache Spark 2.3Spark Saturday: Spark SQL & DataFrame Workshop with Apache Spark 2.3
Spark Saturday: Spark SQL & DataFrame Workshop with Apache Spark 2.3
 
The War on ActionView with Russian Doll Caching
The War on ActionView with Russian Doll CachingThe War on ActionView with Russian Doll Caching
The War on ActionView with Russian Doll Caching
 
Scaling Mapufacture on Amazon Web Services
Scaling Mapufacture on Amazon Web ServicesScaling Mapufacture on Amazon Web Services
Scaling Mapufacture on Amazon Web Services
 
Ruby on Rails Penetration Testing
Ruby on Rails Penetration TestingRuby on Rails Penetration Testing
Ruby on Rails Penetration Testing
 
Building JavaScript
Building JavaScriptBuilding JavaScript
Building JavaScript
 
Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructure
 
Centralized log-management-with-elastic-stack
Centralized log-management-with-elastic-stackCentralized log-management-with-elastic-stack
Centralized log-management-with-elastic-stack
 
Create a new project in ROR
Create a new project in RORCreate a new project in ROR
Create a new project in ROR
 
12 Introduction to Rails
12 Introduction to Rails12 Introduction to Rails
12 Introduction to Rails
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Rails 3 Asset Pipeline

  • 1. Rails Asset Pipeline Nathan Broadbent Onboard Coding Ltd. https://twitter.com/ndbroadbent http://github.com/ndbroadbent
  • 2. Sprockets ● Packages and minifies your JavaScript and CSS assets ● Dependency management ● Pre-processor pipeline – CoffeeScript – SCSS / LESS – Minification
  • 3. Sprockets Directives ● //= require example_asset – searches app/assets/, vendor/assets, lib/assets, <gem>/app/assets – will find: ● example_asset.js ● example_asset.js.coffee ● example_asset.js.coffee.erb ● //= require_tree . – recursively requires all assets in the current directory, including subdirectories
  • 4. Gems to improve the asset pipeline
  • 5. turbo-sprockets-rails3 ● Speeds up rake assets:precompile by only recompiling changed assets, based on a hash of their source files ● Only compiles once to generate both fingerprinted and non-fingerprinted assets
  • 6. turbo-sprockets-rails3 Benchmark on a small Rails app: ● Uninstalled: 26.993s ● Installed – first run: 18.525s – unchanged assets: 9.386s
  • 7. quiet_assets ● Hide asset requests in your Rails logs. ● Lets you focus on SQL queries and rendering ● Just add gem 'quiet_assets' to Gemfile
  • 8. assets_precompile_enforcer ● Raises an exception if an asset is not found in config.assets.precompile ● Avoid 500 errors in production due to uncompiled assets
  • 9. Assets in Rails 4 ● Much faster, don't need turbo-sprockets-rails3 ● Non-digest assets are no longer compiled if fingerprints enabled ● Source maps support: Easily debug errors in minified javascript – http://www.html5rocks.com/en/tutorials/developert ools/sourcemaps/ – If you give your asset source maps to Errbit, it could show you where a production error occurred in the original (unminified) JavaScript