SlideShare a Scribd company logo
1 of 28
SPROCKET
     Optimizing Your JavaScript
 Using Fancy Concatenation Magic
SPROCKET
             Optimizing Your JavaScript
         Using Fancy Concatenation Magic



 this does not
  involve cats
THE PROBLEM
WHAT IS SPROCKETS?
USING IT
THE PROBLEM
WHAT IS SPROCKETS?
USING IT
Maintainability
Structure vs. Performance
Programmer Sanity
Maintainability
Structured and well organized code
Leads to programmer sanity




But there’s an inherent problem…
Structure vs. Performance




   Bigger Applications == More Files!
    Longer load times == Frustrated visitors
THE PROBLEM
WHAT IS SPROCKETS?
USING IT
Ruby Library
  that helps you to...
Turn messy JavaScript *



* otherwise known as zillions of files
Into clean modules for
development
And a single* file for
deployment




* Yes, really. Just the one. No, for real. That’s it. Would I lie to you?
IT’S AWESOME!
THE PROBLEM
WHAT IS SPROCKETS?
USING IT
Installing
It’s a Ruby Gem

You don’t need to know Ruby

But you do need to have Ruby and Ruby Gems installed
Using via Terminal
Using via Terminal




    Example Load Path
Dependencies



//=   require   "sqm"
//=   require   <sqm/admin>
//=   require   <sqm/utilities>
//=   require   <sqm/debugger>
//=   require   <sqm/tooltips>
//=   require   <sqm/lightbox>
//=   require   <sqm/controllers>
//=   require   <sqm/admin/utilities>
Dependencies



//=   require   "sqm"
//=   require   <sqm/admin>
//=   require   <sqm/utilities>
//=   require   <sqm/debugger>
//=   require   <sqm/tooltips>
//=   require   <sqm/lightbox>
//=   require   <sqm/controllers>
//=   require   <sqm/admin/utilities>
Dependencies

//= require <sqm/admin/controllers/versions/lightbox/case_benefit>
//= require <sqm/admin/controllers/versions/spreetabs>




                    //=   require   "sqm"
                    //=   require   <sqm/admin>
                    //=   require   <sqm/utilities>
                    //=   require   <sqm/debugger>
                    //=   require   <sqm/tooltips>
                    //=   require   <sqm/lightbox>
                    //=   require   <sqm/controllers>
                    //=   require   <sqm/admin/utilities>
Comments

// a private comment

/* a public comment */

/** a PDoc comment */
Other things it can do
Insert string constants with <%= %>
Bundle assets to create JS packages
Can run within Ruby code
Can be ran as a Rails plugin (sprocket-rails)
Or as a CGI script
Numbers!

                Non-Optimized   Optimized


    Size           344kb         204kb


HTTP Requests        26            1
Resources

                                I wrote it so that makes me awesome.




                            Sam Stephenson

http://getsprockets.org
http://github.com/sstephenson
http://github.com/sstephenson/sprockets-rails
Thank you!
tim.novinger@gmail.com
@timnovinger




Screaming Monkeys Web Guild   Tim Novinger
17 May 2010                    Squaremouth, Inc.

More Related Content

What's hot

Os Fitzpatrick Sussman Swp
Os Fitzpatrick Sussman SwpOs Fitzpatrick Sussman Swp
Os Fitzpatrick Sussman Swp
oscon2007
 
Gearman: A Job Server made for Scale
Gearman: A Job Server made for ScaleGearman: A Job Server made for Scale
Gearman: A Job Server made for Scale
Mike Willbanks
 

What's hot (19)

Full stack, Full run, Full test
Full stack, Full run, Full testFull stack, Full run, Full test
Full stack, Full run, Full test
 
Os Fitzpatrick Sussman Swp
Os Fitzpatrick Sussman SwpOs Fitzpatrick Sussman Swp
Os Fitzpatrick Sussman Swp
 
Os Alrubaie
Os AlrubaieOs Alrubaie
Os Alrubaie
 
Server-side JavaScript for the rest of us
Server-side JavaScript for the rest of usServer-side JavaScript for the rest of us
Server-side JavaScript for the rest of us
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11
 
Gearman: A Job Server made for Scale
Gearman: A Job Server made for ScaleGearman: A Job Server made for Scale
Gearman: A Job Server made for Scale
 
JRuby - Everything in a single process
JRuby - Everything in a single processJRuby - Everything in a single process
JRuby - Everything in a single process
 
Distributed Queue System using Gearman
Distributed Queue System using GearmanDistributed Queue System using Gearman
Distributed Queue System using Gearman
 
Background processes and tasks in an async world
Background processes and tasks in an async worldBackground processes and tasks in an async world
Background processes and tasks in an async world
 
Vagrant
VagrantVagrant
Vagrant
 
VCR
VCRVCR
VCR
 
Reverse ajax in 2014
Reverse ajax in 2014Reverse ajax in 2014
Reverse ajax in 2014
 
Project development - preparing hell dish together – Oleksii Dashkevych
Project development - preparing hell dish together – Oleksii DashkevychProject development - preparing hell dish together – Oleksii Dashkevych
Project development - preparing hell dish together – Oleksii Dashkevych
 
No more script tag soup!
No more script tag soup!No more script tag soup!
No more script tag soup!
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3
 
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsGearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applications
 
Deploy node.js app with capistrano
Deploy node.js app with capistranoDeploy node.js app with capistrano
Deploy node.js app with capistrano
 
Rubyhosting
RubyhostingRubyhosting
Rubyhosting
 
Web Sockets - HTML5
Web Sockets - HTML5Web Sockets - HTML5
Web Sockets - HTML5
 

Viewers also liked (8)

Sproket pat kk
Sproket pat kkSproket pat kk
Sproket pat kk
 
Sprockets
SprocketsSprockets
Sprockets
 
Chain drives
Chain drivesChain drives
Chain drives
 
BELT TENSIONING METHODS, Chain drive introduction, Power transmitted by chain...
BELT TENSIONING METHODS, Chain drive introduction, Power transmitted by chain...BELT TENSIONING METHODS, Chain drive introduction, Power transmitted by chain...
BELT TENSIONING METHODS, Chain drive introduction, Power transmitted by chain...
 
Chain & Drives Overview
Chain & Drives OverviewChain & Drives Overview
Chain & Drives Overview
 
Chain drives
Chain drivesChain drives
Chain drives
 
Material Selection For A Bicycle
Material Selection For A BicycleMaterial Selection For A Bicycle
Material Selection For A Bicycle
 
2 chain drives
2 chain drives2 chain drives
2 chain drives
 

Similar to Sprockets

Socket applications
Socket applicationsSocket applications
Socket applications
João Moura
 
Using Puppet - Real World Configuration Management
Using Puppet - Real World Configuration ManagementUsing Puppet - Real World Configuration Management
Using Puppet - Real World Configuration Management
James Turnbull
 

Similar to Sprockets (20)

Socket applications
Socket applicationsSocket applications
Socket applications
 
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com RubyConsegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraform
 
Using Puppet - Real World Configuration Management
Using Puppet - Real World Configuration ManagementUsing Puppet - Real World Configuration Management
Using Puppet - Real World Configuration Management
 
Speedy TDD with Rails
Speedy TDD with RailsSpeedy TDD with Rails
Speedy TDD with Rails
 
Lessons Learnt in 2009
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009
 
Automated Java Deployments With Rpm
Automated Java Deployments With RpmAutomated Java Deployments With Rpm
Automated Java Deployments With Rpm
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystem
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
 
Continuous Integration Testing in Django
Continuous Integration Testing in DjangoContinuous Integration Testing in Django
Continuous Integration Testing in Django
 
Sbt, idea and eclipse
Sbt, idea and eclipseSbt, idea and eclipse
Sbt, idea and eclipse
 
Infrastructureascode slideshare-160331143725
Infrastructureascode slideshare-160331143725Infrastructureascode slideshare-160331143725
Infrastructureascode slideshare-160331143725
 
Infrastructureascode slideshare-160331143725
Infrastructureascode slideshare-160331143725Infrastructureascode slideshare-160331143725
Infrastructureascode slideshare-160331143725
 
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
 
JRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the CloudJRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the Cloud
 
rails.html
rails.htmlrails.html
rails.html
 
rails.html
rails.htmlrails.html
rails.html
 
No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010
 
Capistrano
CapistranoCapistrano
Capistrano
 
Capistrano Overview
Capistrano OverviewCapistrano Overview
Capistrano Overview
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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 Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
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
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

Sprockets

Editor's Notes