SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Module Bundling
Agenda
1. Introduction
2. Webpack
3. jspm
Simon Bächler
Web developer at Feinheit
The Problem
• Web sites are turning into Web apps
• Code complexity grows as the site gets bigger
• Developers prefer discrete JS files/modules
• Deployment requires optimized code in just one
or a few HTTP calls
• No standardized import functionality (until now)
<!--[if lt IE 10]>
<script type="text/javascript" src="/static/libs/matchMedia/matchMedia.js"></script>
<script type="text/javascript" src="/static/libs/matchMedia/matchMedia.addListener.js"></script>
<script type="text/javascript" src="/static/libs/1579671/rAF.js"></script>
<![endif]-->
<!-- vendor scripts -->
<script type="text/javascript" src="/static/libs/handlebars/handlebars.min.js"></script>
<script type="text/javascript" src="/static/libs/underscore/underscore.js"></script>
<script type="text/javascript" src="/static/libs/backbone/backbone.js"></script>
<script type="text/javascript" src="/static/libs/backbone-pageable/lib/backbone-pageable.min.js"></script>
<script type="text/javascript" src="/static/libs/jquery-hoverIntent/jquery.hoverIntent.js"></script>
<script type="text/javascript" src="/static/libs/enquire/dist/enquire.min.js"></script>
<script type="text/javascript" src="/static/libs/iCheck/icheck.js"></script>
<script type="text/javascript" src="/static/libs/magnific-popup/dist/jquery.magnific-popup.min.js"></script>
<script type="text/javascript" src="/static/libs/jquery.transit/jquery.transit.js"></script>
<script type="text/javascript" src="/static/libs/jquery.scrollTo/jquery.scrollTo.min.js"></script>
<script type="text/javascript" src="/static/libs/socialcount/dist/socialcount.js"></script>
<script type="text/javascript" src="/static/libs/jQuery-Collapse/src/jquery.collapse.js"></script>
<script type="text/javascript" src="/static/libs/easydropdown/src/jquery.easydropdown.js"></script>
<script type="text/javascript" src="/static/libs/iosslider/_src/jquery.iosslider.min.js"></script>
<script type="text/javascript" src="/static/libs/fastclick/lib/fastclick.js"></script>
<script type="text/javascript" src="/static/libs/moment/min/moment.min.js"></script>
<script type="text/javascript" src="/static/libs/loglevel/dist/loglevel.min.js"></script>
<script type="text/javascript" src="/static/libs/raven-js/dist/raven.min.js"></script>
<!-- end vendor scripts -->
<!-- customized libraries -->
<script type="text/javascript" src="/static/webapp/js/backbone.treemodel.js"></script>
<script type="text/javascript" src="/static/webapp/js/backbone.subset.js"></script>
<script type="text/javascript" src="/static/webapp/js/jquery-ui-1.11.1.custom.min.js"></script>
<script type="text/javascript" src="/static/webapp/js/jquery.ui.datepicker-de-en.js"></script>
<script type="text/javascript" src="/static/webapp/js/moment-locales.js"></script>
<!-- app scripts -->
<script type="text/javascript" src="/static/webapp/js/raven.config.js"></script>
<script type="text/javascript" src="/static/webapp/js/global.js"></script>
<script type="text/javascript" src="/static/webapp/js/footer.js"></script>
<script type="text/javascript" src="/static/webapp/js/breadcrumbs.js"></script>
<script type="text/javascript" src="/static/webapp/js/filters/models.js"></script>
<script type="text/javascript" src="/static/webapp/js/filters/helpers/views.js"></script>
<script type="text/javascript" src="/static/webapp/js/filters/views/singleviews.js"></script>
<script type="text/javascript" src="/static/webapp/js/filters/views/listviews.js"></script>
<script type="text/javascript" src="/static/webapp/js/filters/collections.js"></script>
<script type="text/javascript" src="/static/webapp/js/filters/controller.js"></script>
<script type="text/javascript" src="/static/webapp/js/video.js"></script>
<script type="text/javascript" src="/static/webapp/js/slider.js"></script>
<script type="text/javascript" src="/static/webapp/js/forms.js"></script>
<script type="text/javascript" src="/static/webapp/js/analytics.js"></script>
<script type="text/javascript" src="/static/webapp/js/socialcount.js"></script>
<script type="text/javascript" src="/static/webapp/js/animations.js"></script>
<script type="text/javascript" src="/static/webapp/js/nav/models.js"></script>
<script type="text/javascript" src="/static/webapp/js/nav/views.js"></script>
<script type="text/javascript" src="/static/webapp/js/nav/controller.js"></script>
Javascript Modularization
2010 (Crockford)
var MYAPP = window.MYAPP || {}
MYAPP.Views = {
listView: new ListView(),
detailView: new DetailView()
};
Javascript Modularization
2010 (Crockford)
(function($, MYAPP) {
var app = new MYAPP.App();
app.init($('#container'));
})(jQuery, MYAPP);
True App Modularization
• Code is split up into different modules.
• Dependency graph
• The loading order is irrelevant.
• Code gets executed if all dependencies are
loaded.
• Dependencies can be mocked.
App delivery
• Requests are expensive.
• Deliver as few files as possible.
• Deliver the «above the fold» data first.
• Deliver only code that is needed by the client.
Smart Modularization
common-chunks.js
current-app.js
special-feature1.js special-feature2.js
Assets Versioning
• Adds its hash value to the file name
• Allows for setting long expiration headers
• Requires the HTML to update as well.
• Supported by most popular backends
/static/dist/main-ebf5ec7176585199eb0a.js
Modularization today
CommonJS
var $ = require('jquery');
module.exports = function () {};
Modularization today
AMD
define(['jquery'] , function ($) {
return function () {};
});
Modularization today
ECMA Script 2015
import $ from 'jquery';
function myExample(){};
export default myExample;
Java Script Module Bundlers
• RequireJS (AMD/CommonJS*)
• Browserify (CommonJS/AMD*/ES6*)
• Webpack (CommonJS/AMD/ES6*)
• JSPM / SystemJS (ES6/AMD/CommonJS)
Webpack supports all three
module systems
Configuration based
module.exports = {
context: path.join(__dirname, 'assets'),
entry: {
main: [ 'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./js/main'],
styles: ['./scss/app.scss', './scss/select.less'],
editor: './scss/editor.scss'
},
output: {
path: path.resolve('./assets/build/'),
publicPath: 'http://localhost:3000/assets/build/',
filename: '[name]-[hash].js'
},
devtool: 'source-map',
…
}
loaders: [
{
test: /.jsx?$/,
exclude: /node_modules/,
loaders: ['react-hot', 'babel']},
{
test: /.scss$/,
loader: ExtractTextPlugin.extract(
"css?sourceMap!postcss-loader!sass?" +
"outputStyle=expanded&sourceMap=true")))
},
{
test: /.less/,
loader: ExtractTextPlugin.extract(
"style-loader", "css-loader!less-loader?relative-urls")
},
{
test: /.(png|woff|svg|eot|ttf)$/,
loader: "url-loader?limit=20000"
}
]
Async loading
var films =
document.getElementById('film-gallery');
if(films !== null) {
require.ensure(['lodash'], function(require){
require('./components/FilmApp');
});
}
Hot Module Replacement
DEMO
CSS Live Reload
• No Live Reload with ExtractTextPlugin
• Source maps only with ExtractTextPlugin
(because of WebInspector)
npm is sufficient
npm is the default package manager
and task runner
Production configuration
• Import original configuration
• Overwrite config attributes
• Set NODE_ENV to 'production'
Documentation
jspm.io
jspm / SystemJS
• Package manager (jspm) and module loader
(SystemJS)
• For development: load modules synchronously
• For production: create a bundle
• Support for SPDY (via its own CDN) and possibly
HTTP2
jspm / SystemJS
• In active development
• Uses npm and Github as registries
• A CSS loading plugin is available
• Development != Production environment
DEMO
END OF PART II

Weitere ähnliche Inhalte

Was ist angesagt?

Bundle your modules with Webpack
Bundle your modules with WebpackBundle your modules with Webpack
Bundle your modules with WebpackJake Peyser
 
Packing it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowPacking it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowDerek Willian Stavis
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptLars Thorup
 
Server Side Apocalypse, JS
Server Side Apocalypse, JSServer Side Apocalypse, JS
Server Side Apocalypse, JSMd. Sohel Rana
 
Vue 淺談前端建置工具
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具andyyou
 
Grunt and Bower
Grunt and BowerGrunt and Bower
Grunt and BowerGeorge Estebe
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JSCakra Danu Sedayu
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsk88hudson
 
DotNet MVC and webpack + Babel + react
DotNet MVC and webpack + Babel + reactDotNet MVC and webpack + Babel + react
DotNet MVC and webpack + Babel + reactChen-Tien Tsai
 
NodeWay in my project & sails.js
NodeWay in my project & sails.jsNodeWay in my project & sails.js
NodeWay in my project & sails.jsDmytro Ovcharenko
 
Bower & Grunt - A practical workflow
Bower & Grunt - A practical workflowBower & Grunt - A practical workflow
Bower & Grunt - A practical workflowRiccardo Coppola
 
Node4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorldNode4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorldIan Bull
 
Cli jbug
Cli jbugCli jbug
Cli jbugmaeste
 
Front-end build tools - Webpack
Front-end build tools - WebpackFront-end build tools - Webpack
Front-end build tools - WebpackRazvan Rosu
 
One step in the future: CSS variables
One step in the future: CSS variablesOne step in the future: CSS variables
One step in the future: CSS variablesGiacomo Zinetti
 

Was ist angesagt? (20)

Bundle your modules with Webpack
Bundle your modules with WebpackBundle your modules with Webpack
Bundle your modules with Webpack
 
Webpack
WebpackWebpack
Webpack
 
Packing it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowPacking it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to now
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScript
 
Server Side Apocalypse, JS
Server Side Apocalypse, JSServer Side Apocalypse, JS
Server Side Apocalypse, JS
 
Vue 淺談前端建置工具
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具
 
Npm scripts
Npm scriptsNpm scripts
Npm scripts
 
Lecture: Webpack 4
Lecture: Webpack 4Lecture: Webpack 4
Lecture: Webpack 4
 
Grunt and Bower
Grunt and BowerGrunt and Bower
Grunt and Bower
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JS
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scripts
 
DotNet MVC and webpack + Babel + react
DotNet MVC and webpack + Babel + reactDotNet MVC and webpack + Babel + react
DotNet MVC and webpack + Babel + react
 
Sails js
Sails jsSails js
Sails js
 
NodeWay in my project & sails.js
NodeWay in my project & sails.jsNodeWay in my project & sails.js
NodeWay in my project & sails.js
 
Bower & Grunt - A practical workflow
Bower & Grunt - A practical workflowBower & Grunt - A practical workflow
Bower & Grunt - A practical workflow
 
Node4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorldNode4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorld
 
Cli jbug
Cli jbugCli jbug
Cli jbug
 
Front-end build tools - Webpack
Front-end build tools - WebpackFront-end build tools - Webpack
Front-end build tools - Webpack
 
Nodejs web,db,hosting
Nodejs web,db,hostingNodejs web,db,hosting
Nodejs web,db,hosting
 
One step in the future: CSS variables
One step in the future: CSS variablesOne step in the future: CSS variables
One step in the future: CSS variables
 

Ähnlich wie Javascript Bundling and modularization

Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizationsAnup Hariharan Nair
 
Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
 Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ... Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...Mikko Ohtamaa
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Timothy Fisher
 
Web Components v1
Web Components v1Web Components v1
Web Components v1Mike Wilcox
 
CTU June 2011 - Things that Every ASP.NET Developer Should Know
CTU June 2011 - Things that Every ASP.NET Developer Should KnowCTU June 2011 - Things that Every ASP.NET Developer Should Know
CTU June 2011 - Things that Every ASP.NET Developer Should KnowSpiffy
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScriptkoppenolski
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web AppsTimothy Fisher
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...tdc-globalcode
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introductioncherukumilli2
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web ApplicationYakov Fain
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest servicesIoan Eugen Stan
 
Web Performance Part 4 "Client-side performance"
Web Performance Part 4  "Client-side performance"Web Performance Part 4  "Client-side performance"
Web Performance Part 4 "Client-side performance"Binary Studio
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxKarl-Henry Martinsson
 
Mobile and IBM Worklight Best Practices
Mobile and IBM Worklight Best PracticesMobile and IBM Worklight Best Practices
Mobile and IBM Worklight Best PracticesAndrew Ferrier
 
React basic by Yoav Amit, Wix
React basic by Yoav Amit, Wix React basic by Yoav Amit, Wix
React basic by Yoav Amit, Wix Chen Lerner
 
Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Kile Niklawski
 
ReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparisonReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparison500Tech
 
Going Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and SeamGoing Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and SeamLincoln III
 

Ähnlich wie Javascript Bundling and modularization (20)

Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
 
Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
 Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ... Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
Beautiful Maintainable ModularJavascript Codebase with RequireJS - HelsinkiJ...
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
CTU June 2011 - Things that Every ASP.NET Developer Should Know
CTU June 2011 - Things that Every ASP.NET Developer Should KnowCTU June 2011 - Things that Every ASP.NET Developer Should Know
CTU June 2011 - Things that Every ASP.NET Developer Should Know
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web Apps
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
 
Webpack
Webpack Webpack
Webpack
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web Application
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
Web Performance Part 4 "Client-side performance"
Web Performance Part 4  "Client-side performance"Web Performance Part 4  "Client-side performance"
Web Performance Part 4 "Client-side performance"
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the Box
 
Mobile and IBM Worklight Best Practices
Mobile and IBM Worklight Best PracticesMobile and IBM Worklight Best Practices
Mobile and IBM Worklight Best Practices
 
React basic by Yoav Amit, Wix
React basic by Yoav Amit, Wix React basic by Yoav Amit, Wix
React basic by Yoav Amit, Wix
 
Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Java EE8 - by Kito Mann
Java EE8 - by Kito Mann
 
ReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparisonReactJS vs AngularJS - Head to Head comparison
ReactJS vs AngularJS - Head to Head comparison
 
Going Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and SeamGoing Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and Seam
 

Mehr von stbaechler

Distributed apps
Distributed appsDistributed apps
Distributed appsstbaechler
 
Immutable Libraries for React
Immutable Libraries for ReactImmutable Libraries for React
Immutable Libraries for Reactstbaechler
 
Testing React Applications
Testing React ApplicationsTesting React Applications
Testing React Applicationsstbaechler
 
User stories schreiben
User stories schreibenUser stories schreiben
User stories schreibenstbaechler
 
Nested sets
Nested setsNested sets
Nested setsstbaechler
 
Microformats
MicroformatsMicroformats
Microformatsstbaechler
 
Zeitplanung mit PERT
Zeitplanung mit PERTZeitplanung mit PERT
Zeitplanung mit PERTstbaechler
 
Bower Paketmanager
Bower PaketmanagerBower Paketmanager
Bower Paketmanagerstbaechler
 

Mehr von stbaechler (8)

Distributed apps
Distributed appsDistributed apps
Distributed apps
 
Immutable Libraries for React
Immutable Libraries for ReactImmutable Libraries for React
Immutable Libraries for React
 
Testing React Applications
Testing React ApplicationsTesting React Applications
Testing React Applications
 
User stories schreiben
User stories schreibenUser stories schreiben
User stories schreiben
 
Nested sets
Nested setsNested sets
Nested sets
 
Microformats
MicroformatsMicroformats
Microformats
 
Zeitplanung mit PERT
Zeitplanung mit PERTZeitplanung mit PERT
Zeitplanung mit PERT
 
Bower Paketmanager
Bower PaketmanagerBower Paketmanager
Bower Paketmanager
 

KĂźrzlich hochgeladen

Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Sonam Pathan
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITMgdsc13
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一Fs
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Excelmac1
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一Fs
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Lucknow
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)Christopher H Felton
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 

KĂźrzlich hochgeladen (20)

Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 

Javascript Bundling and modularization

  • 4. The Problem • Web sites are turning into Web apps • Code complexity grows as the site gets bigger • Developers prefer discrete JS files/modules • Deployment requires optimized code in just one or a few HTTP calls • No standardized import functionality (until now)
  • 5. <!--[if lt IE 10]> <script type="text/javascript" src="/static/libs/matchMedia/matchMedia.js"></script> <script type="text/javascript" src="/static/libs/matchMedia/matchMedia.addListener.js"></script> <script type="text/javascript" src="/static/libs/1579671/rAF.js"></script> <![endif]--> <!-- vendor scripts --> <script type="text/javascript" src="/static/libs/handlebars/handlebars.min.js"></script> <script type="text/javascript" src="/static/libs/underscore/underscore.js"></script> <script type="text/javascript" src="/static/libs/backbone/backbone.js"></script> <script type="text/javascript" src="/static/libs/backbone-pageable/lib/backbone-pageable.min.js"></script> <script type="text/javascript" src="/static/libs/jquery-hoverIntent/jquery.hoverIntent.js"></script> <script type="text/javascript" src="/static/libs/enquire/dist/enquire.min.js"></script> <script type="text/javascript" src="/static/libs/iCheck/icheck.js"></script> <script type="text/javascript" src="/static/libs/magnific-popup/dist/jquery.magnific-popup.min.js"></script> <script type="text/javascript" src="/static/libs/jquery.transit/jquery.transit.js"></script> <script type="text/javascript" src="/static/libs/jquery.scrollTo/jquery.scrollTo.min.js"></script> <script type="text/javascript" src="/static/libs/socialcount/dist/socialcount.js"></script> <script type="text/javascript" src="/static/libs/jQuery-Collapse/src/jquery.collapse.js"></script> <script type="text/javascript" src="/static/libs/easydropdown/src/jquery.easydropdown.js"></script> <script type="text/javascript" src="/static/libs/iosslider/_src/jquery.iosslider.min.js"></script> <script type="text/javascript" src="/static/libs/fastclick/lib/fastclick.js"></script> <script type="text/javascript" src="/static/libs/moment/min/moment.min.js"></script> <script type="text/javascript" src="/static/libs/loglevel/dist/loglevel.min.js"></script> <script type="text/javascript" src="/static/libs/raven-js/dist/raven.min.js"></script> <!-- end vendor scripts --> <!-- customized libraries --> <script type="text/javascript" src="/static/webapp/js/backbone.treemodel.js"></script> <script type="text/javascript" src="/static/webapp/js/backbone.subset.js"></script> <script type="text/javascript" src="/static/webapp/js/jquery-ui-1.11.1.custom.min.js"></script> <script type="text/javascript" src="/static/webapp/js/jquery.ui.datepicker-de-en.js"></script> <script type="text/javascript" src="/static/webapp/js/moment-locales.js"></script> <!-- app scripts --> <script type="text/javascript" src="/static/webapp/js/raven.config.js"></script> <script type="text/javascript" src="/static/webapp/js/global.js"></script> <script type="text/javascript" src="/static/webapp/js/footer.js"></script> <script type="text/javascript" src="/static/webapp/js/breadcrumbs.js"></script> <script type="text/javascript" src="/static/webapp/js/filters/models.js"></script> <script type="text/javascript" src="/static/webapp/js/filters/helpers/views.js"></script> <script type="text/javascript" src="/static/webapp/js/filters/views/singleviews.js"></script> <script type="text/javascript" src="/static/webapp/js/filters/views/listviews.js"></script> <script type="text/javascript" src="/static/webapp/js/filters/collections.js"></script> <script type="text/javascript" src="/static/webapp/js/filters/controller.js"></script> <script type="text/javascript" src="/static/webapp/js/video.js"></script> <script type="text/javascript" src="/static/webapp/js/slider.js"></script> <script type="text/javascript" src="/static/webapp/js/forms.js"></script> <script type="text/javascript" src="/static/webapp/js/analytics.js"></script> <script type="text/javascript" src="/static/webapp/js/socialcount.js"></script> <script type="text/javascript" src="/static/webapp/js/animations.js"></script> <script type="text/javascript" src="/static/webapp/js/nav/models.js"></script> <script type="text/javascript" src="/static/webapp/js/nav/views.js"></script> <script type="text/javascript" src="/static/webapp/js/nav/controller.js"></script>
  • 6. Javascript Modularization 2010 (Crockford) var MYAPP = window.MYAPP || {} MYAPP.Views = { listView: new ListView(), detailView: new DetailView() };
  • 7. Javascript Modularization 2010 (Crockford) (function($, MYAPP) { var app = new MYAPP.App(); app.init($('#container')); })(jQuery, MYAPP);
  • 8. True App Modularization • Code is split up into different modules. • Dependency graph • The loading order is irrelevant. • Code gets executed if all dependencies are loaded. • Dependencies can be mocked.
  • 9. App delivery • Requests are expensive. • Deliver as few files as possible. • Deliver the ÂŤabove the foldÂť data first. • Deliver only code that is needed by the client.
  • 11. Assets Versioning • Adds its hash value to the file name • Allows for setting long expiration headers • Requires the HTML to update as well. • Supported by most popular backends /static/dist/main-ebf5ec7176585199eb0a.js
  • 12. Modularization today CommonJS var $ = require('jquery'); module.exports = function () {};
  • 13. Modularization today AMD define(['jquery'] , function ($) { return function () {}; });
  • 14. Modularization today ECMA Script 2015 import $ from 'jquery'; function myExample(){}; export default myExample;
  • 15. Java Script Module Bundlers • RequireJS (AMD/CommonJS*) • Browserify (CommonJS/AMD*/ES6*) • Webpack (CommonJS/AMD/ES6*) • JSPM / SystemJS (ES6/AMD/CommonJS)
  • 16.
  • 17.
  • 18. Webpack supports all three module systems
  • 19. Configuration based module.exports = { context: path.join(__dirname, 'assets'), entry: { main: [ 'webpack-dev-server/client?http://localhost:3000', 'webpack/hot/only-dev-server', './js/main'], styles: ['./scss/app.scss', './scss/select.less'], editor: './scss/editor.scss' }, output: { path: path.resolve('./assets/build/'), publicPath: 'http://localhost:3000/assets/build/', filename: '[name]-[hash].js' }, devtool: 'source-map', … }
  • 20. loaders: [ { test: /.jsx?$/, exclude: /node_modules/, loaders: ['react-hot', 'babel']}, { test: /.scss$/, loader: ExtractTextPlugin.extract( "css?sourceMap!postcss-loader!sass?" + "outputStyle=expanded&sourceMap=true"))) }, { test: /.less/, loader: ExtractTextPlugin.extract( "style-loader", "css-loader!less-loader?relative-urls") }, { test: /.(png|woff|svg|eot|ttf)$/, loader: "url-loader?limit=20000" } ]
  • 21. Async loading var films = document.getElementById('film-gallery'); if(films !== null) { require.ensure(['lodash'], function(require){ require('./components/FilmApp'); }); }
  • 23. CSS Live Reload • No Live Reload with ExtractTextPlugin • Source maps only with ExtractTextPlugin (because of WebInspector)
  • 24. npm is sufficient npm is the default package manager and task runner
  • 25. Production configuration • Import original configuration • Overwrite config attributes • Set NODE_ENV to 'production'
  • 28. jspm / SystemJS • Package manager (jspm) and module loader (SystemJS) • For development: load modules synchronously • For production: create a bundle • Support for SPDY (via its own CDN) and possibly HTTP2
  • 29. jspm / SystemJS • In active development • Uses npm and Github as registries • A CSS loading plugin is available • Development != Production environment
  • 30. DEMO

Hinweis der Redaktion

  1. This talk has two parts Part 2 is much shorter.
  2. This is an actual portrait of me, drawn by the very talented Tika.
  3. From Require.js
  4. Real Website example: 45 Scripts Server side Bundler No explicit dependencies in the scripts. Bundler does not value dependencies. Order of the scripts is important
  5. Global Object, provides a namespace. Everything goes into that object.
  6. Closure Does not pollute global namespace. Dependency on global objects. Unit testing is difficult
  7. Modules define their dependencies. Module loaders build a dependency graph and package the modules accordingly. Dependency Injection.
  8. Modularization competes with delivery over HTTP (1). Think about how you package your assets.
  9. The app should deliver several static files: A common-chunks.js file with all the code that is shared over multiple pages. So it can be cached by the browser. A Js file with code specific for the current app. Code for sections wich are rarely used or needs a big library should be split out into a separate module which is loaded asynchronously on-demand.
  10. e.g. Webpack exports a JSON with the asset targets and file names. Django has a library called django-webpack-loader that reads that JSON and adds the data into the HTML template. It also waits for Webpack to complete building if necessary.
  11. CommonJS: Introduced with Node.js. Designed for synchronous loading. (Browserify) Problem: It doesn’t work in the browser.
  12. Asynchronous Module Definition (AMD): Designed for asynchronous loading. Runs a callback when ready. A bit like $(function(){}); Require.js, Angular.js UMD: Universal Module Definition (for libraries)
  13. CommonJS: Designed for synchronous loading. (Browserify) Asynchronous Module Definition (AMD): Designed for asynchronous loading. Require.js, Angular.js UMD: Universal Module Definition (for libraries)
  14. Currently 3 popular bundlers. JSPM is very new. With plugins
  15. Survey in August 2015. Half the people are using a module bundler. Ashley Nolan http://ashleynolan.co.uk/blog/frontend-tooling-survey-2015-results
  16. By Tobias Koppers. This is a free-time project. MIT license
  17. Compared to Browserify it can split the code into multiple modules. Component structure: CSS and Image are also part of a component and can therefore be included. CSS load order is not guaranteed if CSS is embedded in the Javascript files. You can extract the CSS into its own file.
  18. The configuration is a Javascript object. Because it is a CommonJS module, configurations can be extended by other modules. E.g. a production config can just import the default configuration and overwrite the necessary properties.
  19. Assets are loaded using a loader. The test property is a regex that is applied to all the files in a directory. Loaders can be chained and passed attributes. The first loader tests for js and jsx files and uses babel to parse ES6 code. SCSS and LESS loaders can work in the same project. (3rd party library used less). URL loader copies the files if they are less than 20kB. Otherwise it embeds them. Copied files can be given a hash-name.
  20. Automatically creates separate bundles for parts of the app that are only needed on demand. Here the FilmApp is a large React application that is only loaded if an element with the ID 'film-gallery' is present in the DOM.
  21. Webpack Dev server stores files in memory.
  22. You have to chose between live reload and source maps. Web inspector only shows source maps for css if the source file is a CSS file.
  23. Bower can be used, but it is not necessary. No Gulp required. (Gulp can be used but makes the builds slower.) NPM is the default package manager (and task runner)
  24. Have a separate config file for production builds. Replace destination paths, add ugilfyJS NODE_ENV environment variable is used by React to remove debugging statements.
  25. jspm is a package manager for the SystemJS universal module loader, built on top of the dynamic ES6 module loader SystemJS is a Polyfill for the System specification
  26. There is no Javascript watch and compiling tasks in development.
  27. jspm Version 0.16.0 was released on 18. August. jspm Version 0.16.6 was released on 19. September. 7 Releases in one Month. SystemJS: 6 releases in the last two weeks. Sass loader plugin is still in alpha stage.
  28. Any questions so far?