SlideShare a Scribd company logo
Pack it!
JavaScript software packaging from 2000 to now
$ whois
Derek Stavis
github.com/derekstavis
Software Engineer @ Pagar.me
Node, React & Webpack Advocate
–See no evil monkey
“Webpack is just a module bundler.”
🙈
Why do we need a
module bundler?
Why we need
module bundling
early web
<html>
<head>
<script src="header.js"></script>
<script src="menu.js"></script>
<script src="sidebar.js"></script>
<script src="fancy-button.js"></script>
<script src="carousel.js"></script>
</head>
<body>
</body>
</html>
2003
JSMin
The JavaScript Minifier
Douglas Crockford
www.crockford.com
2003-12-04
JSMin is a filter which removes comments and unnecessary whitespace from JavaScript files. It typically reduces filesize by half, resulting
in faster downloads. It also encourages a more expressive programming style because it eliminates the download cost of clean, literate
self-documentation.
What JSMin Does
JSMin is a filter that omits or modifies some characters. This does not change the behavior of the program that it is minifying. The result
may be harder to debug. It will definitely be harder to read.
JSMin first replaces carriage returns ('r') with linefeeds ('n'). It replaces all other control characters (including tab) with spaces. It
replaces comments in the // form with linefeeds. It replaces comments in the /* */ form with spaces. All runs of spaces are replaced with
a single space. All runs of linefeeds are replaced with a single linefeed.
It omits spaces except when a space is preceded and followed by a non-ASCII character or by an ASCII letter or digit, or by one of these
characters:
 $ _
It is more conservative in omitting linefeeds, because linefeeds are sometimes treated as semicolons. A linefeed is not omitted if it
precedes a non-ASCII character or an ASCII letter or digit or one of these characters:
 $ _ { [ ( + -
and if it follows a non-ASCII character or an ASCII letter or digit or one of these characters:
 $ _ } ] ) + - " '
No other characters are omitted or modified.
<html>
<head>
<script src="header.min.js"></script>
<script src="menu.min.js"></script>
<script src="sidebar.min.js"></script>
<script src="fancy-button.min.js"></script>
<script src="carousel.min.js"></script>
</head>
<body>
</body>
</html>
still too many files
use all browser
connections
add request overhead
hard to invalidate cache
let’s concatenate files
wrap every file with an IIFE
;(function () {
var counter = 0
...
})();
;(function () {
var xpto = 0
...
})();
to isolate file scope
each file is now a module
concatenate all files
now you have the bundle
<html>
<head>
<script src="app.min.js"></script>
</head>
<body>
</body>
</html>
2006
jQuery
New Wave Javascript
jQuery is a new type of Javascript library. It is not a huge, bloated, framework
promising the best in AJAX - nor is just a set of needlessly complex
enhancements - jQuery is designed to change the way that you write
Javascript.
New: The jQuery Mailing List is now up - join and discuss!
New: The jQuery Blog has just been opened - subscribe now!
What is jQuery?
jQuery is a Javascript library that takes this motto to heart: Writing Javascript
code should be fun. jQuery acheives this goal by taking common, repetitive,
tasks, stripping out all the unnecessary markup, and leaving them short, smart
and understandable.
What does jQuery code look like? The quick and dirty:
The above code snippet looks for all paragraphs that have a class of 'surprise',
adds the class 'ohmy' to them, then slowly reveals them. Click the 'Run' button
to see it in action!
Quick Facts:
jQuery supports CSS 1-3 and basic XPath.
jQuery is about 10kb in size.
jQuery works in Internet Explorer, Firefox, Safari, and Opera.
Getting Started:
$("p.surprise").addClass("ohmy").show("slow");
Congratulations! You just ran a snippet of jQuery code - wasn't that
easy? There's lots of example code throughout the documentation, on
this site - be sure to give all the code a test run, to see what happens.
jQuery popularized AJAX
lots of community plugins
some problems too
<html>
<head>
<script src="jquery.min.js"></script>
...
<script src="jquery.soundy.min.js"></script>
<script src="jquery.fancy.min.js"></script>
<script src="jquery.blinky.min.js"></script>
<script src="photo-gallery.min.js"></script>
</head>
<body>
</body>
</html>
<html>
<head>
<script src="jquery.min.js"></script>
...
<script src="jquery.soundy.min.js"></script>
<script src="jquery.fancy.min.js"></script>
<script src="jquery.blinky.min.js"></script>
<script src="about-us.min.js"></script>
</head>
<body>
</body>
</html>
<html>
<head>
<script src="jquery.min.js"></script>
...
<script src="jquery.soundy.min.js"></script>
<script src="jquery.fancy.min.js"></script>
<script src=“jquery.blinky.min.js"></script>
<script src="contact-us.min.js"></script>
</head>
<body>
</body>
</html>
manual dependency order
script tag ordering hell
2007
and it included…
a real browser!
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team at JavaScript 3 Dia
to mimic real apps
web apps had to be light
they had to be smooth
we already had async http
let’s do more single page
<html>
<head>
<script src="jquery.min.js"></script>
...
<script src="jquery.soundy.min.js"></script>
<script src="jquery.fancy.min.js"></script>
<script src="jquery.blinky.min.js"></script>
<script src="app.min.js"></script>
</head>
<body>
</body>
</html>
in this new approach
full app was downloaded
even unneeded code
we needed lazy load
dependency ordering
2009
commonjs is born
r.js is born
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team at JavaScript 3 Dia
hello async modules
<html>
<head>
<script src="r.js"></script>
<script>
require(["app.js"])
</script>
</head>
<body>
</body>
</html>
index.html
app.js
require(["jquery.fancy", "jquery.soundy"], function () {
$(".target").fancy()
})
now single page apps
could load app code
progressively
but with dependencies
comes managing
we used to
download and drop .min.js
in the project
version control was hard
2010
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team at JavaScript 3 Dia
JavaScript outside browser
module based from day 0
set us free from browser
brought sane packages
a package manager
with the power of node
lots of tools were created
solving pains from the past
also in the same year
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team at JavaScript 3 Dia
suddenly we were writing
not just web pages
but entire applications
2012
after lots of nasty scripts
a boom of task managers
we created extensive
gruntfiles
gulpfiles
2014
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team at JavaScript 3 Dia
React became popular
Webpack had its glory
since then
we have been doing nice
lots of overhead is over
2017
const path = require('path')
module.exports = {
entry: './index.js',
output: {
path: path.join(__dirname, 'dist'),
filename: "bundle.js",
},
module: {
rules: [
{
test: /.js$/,
use: ['babel-loader'],
},
{
test: /.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /.(svg|otf|woff|woff2|ttf|otf|png|jpg|gif)$/,
use: ['file-loader'],
}
]
}
}
module
bundler
builds a dependency tree
by walking though imports
every single dependency
of your system is a module
loaders are the key point
have standard interface
take an input
output transformed
content
J S X J S ( E S 5 )
babel-loader
S C S S C S S
postcss-loader
P N G B A S E 6 4
url-loader
B U N D L E . J S
outputs can be
chunks or files
chunks are text modules
concatenated in bundle
files are emitted in
output directory
a handful of loaders
url-loader
file-loader
json-loader
json5-loader
script-loader
babel-loader
coffee-loader
html-loader
pug-loader
jade-loader
style-loader
css-loader
sass-loader
less-loader
postcss-loader
eslint-loader
loaders can be piped
const path = require('path')
module.exports = {
entry: './index.js',
output: {
path: path.join(__dirname, 'dist'),
filename: "bundle.js",
},
module: {
rules: [
{
test: /.js$/,
use: ['babel-loader'],
},
{
test: /.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /.(svg|otf|woff|woff2|ttf|otf|png|jpg|gif)$/,
use: ['file-loader'],
}
]
}
}
lazy module loading
split bundles
incremental builds
hot module replacement
what all this means?
demo time
https://web-beta.archive.org/web/20060201000000*/http://
jquery.com
http://www.crockford.com/javascript/jsmin.html
http://gizmodo.com/5072967/iphone-secret-web-apps-can-
mimic-real-apps
https://web.archive.org/web/20071011085815/http://
developer.yahoo.com/common/json.html

More Related Content

PDF
PDF
Webpack packing it all
PDF
Node.js & Twitter Bootstrap Crash Course
PDF
Packing it all: JavaScript module bundling from 2000 to now
PDF
Nuxt.JS Introdruction
PPTX
Lecture: Webpack 4
PDF
Node PDX: Intro to Sails.js
Webpack packing it all
Node.js & Twitter Bootstrap Crash Course
Packing it all: JavaScript module bundling from 2000 to now
Nuxt.JS Introdruction
Lecture: Webpack 4
Node PDX: Intro to Sails.js

What's hot (20)

PDF
jQuery Conference San Diego 2014 - Web Performance
PPTX
jQuery Conference 2012 keynote
PPTX
Packing for the Web with Webpack
PDF
Webpack Tutorial, Uppsala JS
PDF
Why NodeJS
PDF
The Onion
PPTX
An Intro into webpack
PDF
Nuxt.js - Introduction
PPTX
Don't Over-React - just use Vue!
PPT
Js unit testing
PPTX
KEY
Thats Not Flash?
PDF
Learning jQuery @ MIT
KEY
New Perspectives on Performance
PPTX
Require js
PDF
[jqconatx] Adaptive Images for Responsive Web Design
PPTX
Vue js for beginner
PPTX
Bower power
PDF
Vue JS Intro
PDF
Node.js Crash Course (Jump Start)
jQuery Conference San Diego 2014 - Web Performance
jQuery Conference 2012 keynote
Packing for the Web with Webpack
Webpack Tutorial, Uppsala JS
Why NodeJS
The Onion
An Intro into webpack
Nuxt.js - Introduction
Don't Over-React - just use Vue!
Js unit testing
Thats Not Flash?
Learning jQuery @ MIT
New Perspectives on Performance
Require js
[jqconatx] Adaptive Images for Responsive Web Design
Vue js for beginner
Bower power
Vue JS Intro
Node.js Crash Course (Jump Start)
Ad

Similar to TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team at JavaScript 3 Dia (20)

PPTX
JavaScript Perfomance
PPTX
JavaScript Performance (at SFJS)
PDF
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
PPT
Sanjeev ghai 12
KEY
Developing High Performance Web Apps - CodeMash 2011
KEY
[Coscup 2012] JavascriptMVC
PDF
Meetup Performance
PDF
Meetup Performance
PDF
Webpack Encore - Asset Management for the rest of us
PDF
Ajax Performance Tuning and Best Practices
PDF
Javascript ui for rest services
PPTX
Building high performance web apps.
PDF
Developing High Performance Web Apps
PPT
Build Your Own CMS with Apache Sling
PDF
Web-Performance
PDF
Scott Jehl - Delivering Responsibly - beyond tellerrand Düsseldorf 2015
PDF
WebNet Conference 2012 - Designing complex applications using html5 and knock...
PDF
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
KEY
Taking your Web App for a walk
PPTX
Javascript first-class citizenery
JavaScript Perfomance
JavaScript Performance (at SFJS)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
Sanjeev ghai 12
Developing High Performance Web Apps - CodeMash 2011
[Coscup 2012] JavascriptMVC
Meetup Performance
Meetup Performance
Webpack Encore - Asset Management for the rest of us
Ajax Performance Tuning and Best Practices
Javascript ui for rest services
Building high performance web apps.
Developing High Performance Web Apps
Build Your Own CMS with Apache Sling
Web-Performance
Scott Jehl - Delivering Responsibly - beyond tellerrand Düsseldorf 2015
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Taking your Web App for a walk
Javascript first-class citizenery
Ad

More from tdc-globalcode (20)

PDF
TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidade
PDF
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...
PDF
TDC2019 Intel Software Day - ACATE - Cases de Sucesso
PDF
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPA
PDF
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVino
PDF
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...
PDF
TDC2019 Intel Software Day - Inferencia de IA em edge devices
PDF
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publica
PPT
Trilha .Net - Programacao funcional usando f#
PDF
TDC2018SP | Trilha Go - Case Easylocus
PDF
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?
PDF
TDC2018SP | Trilha Go - Clean architecture em Golang
PDF
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QA
PDF
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendencia
PDF
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Service
PDF
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NET
PDF
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
PDF
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...
PDF
TDC2018SP | Trilha .Net - .NET funcional com F#
PDF
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor em .Net Core
TDC2019 Intel Software Day - Visao Computacional e IA a servico da humanidade
TDC2019 Intel Software Day - Tecnicas de Programacao Paralela em Machine Lear...
TDC2019 Intel Software Day - ACATE - Cases de Sucesso
TDC2019 Intel Software Day - Otimizacao grafica com o Intel GPA
TDC2019 Intel Software Day - Deteccao de objetos em tempo real com OpenVino
TDC2019 Intel Software Day - OpenCV: Inteligencia artificial e Visao Computac...
TDC2019 Intel Software Day - Inferencia de IA em edge devices
Trilha BigData - Banco de Dados Orientado a Grafos na Seguranca Publica
Trilha .Net - Programacao funcional usando f#
TDC2018SP | Trilha Go - Case Easylocus
TDC2018SP | Trilha Modern Web - Para onde caminha a Web?
TDC2018SP | Trilha Go - Clean architecture em Golang
TDC2018SP | Trilha Go - "Go" tambem e linguagem de QA
TDC2018SP | Trilha Mobile - Digital Wallets - Seguranca, inovacao e tendencia
TDC2018SP | Trilha .Net - Real Time apps com Azure SignalR Service
TDC2018SP | Trilha .Net - Passado, Presente e Futuro do .NET
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Obtendo metricas com TDD utilizando build automatiz...
TDC2018SP | Trilha .Net - .NET funcional com F#
TDC2018SP | Trilha .Net - Crie SPAs com Razor e C# usando Blazor em .Net Core

Recently uploaded (20)

PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Basic Mud Logging Guide for educational purpose
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Renaissance Architecture: A Journey from Faith to Humanism
Insiders guide to clinical Medicine.pdf
Final Presentation General Medicine 03-08-2024.pptx
01-Introduction-to-Information-Management.pdf
TR - Agricultural Crops Production NC III.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Anesthesia in Laparoscopic Surgery in India
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
VCE English Exam - Section C Student Revision Booklet
Pharmacology of Heart Failure /Pharmacotherapy of CHF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
O5-L3 Freight Transport Ops (International) V1.pdf
Basic Mud Logging Guide for educational purpose

TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team at JavaScript 3 Dia