SlideShare ist ein Scribd-Unternehmen logo
1 von 58
Downloaden Sie, um offline zu lesen
Dependencies & Modules

Wednesday, January 8, 14

To handle dependencies and modules in a simple way we need some proper tooling.
Wednesday, January 8, 14

Then talk a bit about Browserify.
Wednesday, January 8, 14

I’ve been writing JS for quite a while, then I was off doing mostly backend & Android for while.
This is Theo, I felt like him here towards JS for a while I feel that the tools around for JS has increased and grown in complexity quite fast. It also feels like it is
changing quite rapid. This is also what attracts me to JS, for me it feels like this is where a lot of creativity and innovation is happening.
But picking the right tools is a/has been challenge.
Web Sites vs Web Apps
What’s the difference?

Wednesday, January 8, 14

I find this quite interesting. And is there a difference and why do we make a difference?
We’re all building sites that people visit, do
something, and leave. Differentiating websites vs. web
apps is no good to anyone.
– Jack Franklin
https://speakerdeck.com/jackfranklin/port80-practical-javascripting

Wednesday, January 8, 14
Why do you want to make that distinction?
What benefit do you gain by arbitrarily dividing
the entire web into two classes?
– Jeremy Keith
http://adactio.com/journal/6246/

Wednesday, January 8, 14
A lot of people ignore new JavaScript tools, methods
or approaches because those are just for “web apps.”
– Jack Franklin
https://speakerdeck.com/jackfranklin/port80-practical-javascripting

Wednesday, January 8, 14

I’ve done this for too long.
Dev Environment
•

Module System: A way to programmatically load scripts when they’re
needed.

•

Package Manager: Fetch scripts from online sources like GitHub, taking
dependencies into account.

•

Build Tool: Combine scripts and other assets together into something
usable by browsers.
http://dailyjs.com/2013/01/28/components/

Wednesday, January 8, 14

And to handle modules and dependencies properly we need to use proper tools to cope with a modern development environment
Modules
A way to programmatically load scripts when they’re needed

Wednesday, January 8, 14

Let’s start with modules.
What is a module? Keep it simple, it’s basically just a script that we can load whenever we need it.
<script
<script
<script
<script
<script
<script
<script
<script
<script
<script

type="text/javascript"
type="text/javascript"
type="text/javascript"
type="text/javascript"
type="text/javascript"
type="text/javascript"
type="text/javascript"
type="text/javascript"
type="text/javascript"
type="text/javascript"

src="/js/namespace.js"></script>
src="/js/vendor/buffer-loader.js"></script>
src="/js/vendor/requestanimframe.js"></script>
src="/js/vendor/stats.min.js"></script>
src="/js/vendor/minpubsub.js"></script>
src="/js/app.js"></script>
src="/js/utils.js"></script>
src="/js/sound.js"></script>
src="/js/shape.js"></script>
src="/js/main.js"></script>

Wednesday, January 8, 14

We can easily do this by separating our code into various scripts. It gets a bit troublesome to manage this though. For me this way hinders me from playing
around and prototyping and testing things out while developing.
SRC_DIR = src
BUILD_DIR = build
JS_SERVER_FILES = $(SRC_DIR)/js/namespace.js
! $(SRC_DIR)/js/vendor/buffer-loader.js
! $(SRC_DIR)/js/vendor/requestanimframe.js
! $(SRC_DIR)/js/vendor/stats.min.js
! $(SRC_DIR)/js/vendor/minpubsub.js
! $(SRC_DIR)/js/app.js
! $(SRC_DIR)/js/utils.js
! $(SRC_DIR)/js/sound.js
! $(SRC_DIR)/js/shape.js
! $(SRC_DIR)/js/main.js
JS_BUNDLE = $(BUILD_DIR)/app.js
BUILD_BUNDLE = $(BUILD_DIR)/app-min.js
.DEFAULT_GOAL := all
all: bundle
! java -jar $(GCC_COMPRESSOR) $(GCC_OPTION) --js=$(JS_BUNDLE) -js_output_file=$(BUILD_BUNDLE)
debug: bundle
! cat $(JS_FILES) >> $(JS_BUNDLE)
Wednesday, January 8, 14

To assemble this for production we would need a build script. This is a Makefile from an old project of mine. Sure we can have grunt but it is still configuration
clean:
we need to add.

! rm -Rf $(BUILD_DIR)/*

For me this isn’t really prototyping friendly.
<% if (production) { %>
<script type="text/javascript"
<% } else { %>
<script type="text/javascript"
<script type="text/javascript"
<script type="text/javascript"
<script type="text/javascript"
<script type="text/javascript"
<script type="text/javascript"
<script type="text/javascript"
<script type="text/javascript"
<script type="text/javascript"
<script type="text/javascript"
<% } %>

src="/js/app-min.js"></script>
src="/js/namespace.js"></script>
src="/js/vendor/buffer-loader.js"></script>
src="/js/vendor/requestanimframe.js"></script>
src="/js/vendor/stats.min.js"></script>
src="/js/vendor/minpubsub.js"></script>
src="/js/app.js"></script>
src="/js/utils.js"></script>
src="/js/sound.js"></script>
src="/js/shape.js"></script>
src="/js/main.js"></script>

Wednesday, January 8, 14

And we add a conditional to check if we are in production. Personally I don’t like this since it means that we’re during development will most likely run a different
version of the site than we will in production.
The Problem
•
•
•
•

Code complexity grows as the site gets bigger
Assembly gets harder
Developer wants discrete JS files/modules
Deployment wants optimized code in just one or a few HTTP calls

http://requirejs.org/docs/why.html#1
Wednesday, January 8, 14

Why do we want modules. Require.JS outlines a few arguments on there website.
We basically want it because we need better structure in our code.
Current Landscape
•
•
•
•
•
•

Globals
Globals + Namespace
AMD (Asynchronous Module Definition)
CommonJS
UMD (Universal Module Definition)
(ES6)

Wednesday, January 8, 14

Alternatives for modules, not taking framework specific ones like Angular into account.
var isEven = function(i) {
return i % 2 === 0;
};

Wednesday, January 8, 14

I like small bits of code that can be separated and re-used. Here’s a quite simple re-usable bit of code but is short enough to fit a slide.
Simple re-usable code
Globals

Wednesday, January 8, 14
even.js

var isEven = function(i) {
return i % 2 === 0;
};

Wednesday, January 8, 14
app.js
console.log(1,
console.log(2,
console.log(3,
console.log(4,

Wednesday, January 8, 14

isEven(1));
isEven(2));
isEven(3));
isEven(4));
index.html
<!doctype html>
<script src="even.js"></script>
<script src="app.js"></script>

Wednesday, January 8, 14
Globals + Namespace

Wednesday, January 8, 14
app-even.js
var App = App || {};
App.isEven = function(i) {
return i % 2 === 0;
};

Wednesday, January 8, 14
app.js
var App = App || {};
console.log(1,
console.log(2,
console.log(3,
console.log(4,

Wednesday, January 8, 14

App.isEven(1));
App.isEven(2));
App.isEven(3));
App.isEven(4));
index.html

<!doctype html>
<script src="app-even.js"></script>
<script src="app.js"></script>

Wednesday, January 8, 14
AMD
Asynchronous Module Definition
With Require.JS

Wednesday, January 8, 14
even.js
define([], function() {
var isEven = function(i) {
return i % 2 === 0;
};
return isEven;
});

Wednesday, January 8, 14
app.js
require(['even'], function(even){
console.log(1, even(1));
console.log(2, even(2));
console.log(3, even(3));
console.log(4, even(4));
});

Wednesday, January 8, 14
index.html

<!doctype html>
<script data-main="js/app.js"
src="js/require.js"></script>

Wednesday, January 8, 14
//Allow for anonymous modules
if (typeof name !== 'string') {
//Adjust args appropriately
callback = deps;
deps = name;
name = null;
}
//This module may not have dependencies
if (!isArray(deps)) {
callback = deps;
deps = null;
}

require.js

//If no name, and callback is a function, then figure out if it a
//CommonJS thing with dependencies.
if (!deps && isFunction(callback)) {
deps = [];
//Remove comments from the callback string,
//look for require calls, and pull them into the dependencies,
//but only if there are function args.
if (callback.length) {
callback
.toString()
.replace(commentRegExp, '')
.replace(cjsRequireRegExp, function (match, dep) {
deps.push(dep);
});

//May be a CommonJS thing even without require calls, but still
//could use exports, and module. Avoid doing exports and module
//work though if it just needs require.
//REQUIRES the function to expect the CommonJS variables in the
//order listed below.
deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);
}
}
//If in IE 6-8 and hit an anonymous define() call, do the interactive
//work.
if (useInteractive) {
node = currentlyAddingScript || getInteractiveScript();
if (node) {
if (!name) {
name = node.getAttribute('data-requiremodule');
}
context = contexts[node.getAttribute('data-requirecontext')];
}
}
//Always save off evaluating the def call until the script onload handler.
//This allows multiple modules to be in a file without prematurely
//tracing dependencies, and allows for anonymous module support,
//where the module name is not known until the script onload event
//occurs. If no context, use the global queue, and get it processed
//in the onscript load callback.
(context ? context.defQueue : globalDefQueue).push([name, deps, callback]);
};
define.amd = {
jQuery: true
};

Wednesday, January 8, 14

/**
* Executes the text. Normally just uses eval, but can be modified
* to use a better, environment-specific call. Only used for transpiling
* loader plugins, not for plain JS modules.
* @param {String} text the text to execute/evaluate.
*/
req.exec = function (text) {
/*jslint evil: true */
return eval(text);
};

Quite a massive file that is required //Set load these files. Not sure exactly what goes on here, but it works.
to up with config info.
req(cfg);
}(this));
Makefile / Build step

build:
! node r.js -o name=app out=js/app-built.js baseUrl=./js
build-even:
! node r.js -o name=even out=js/even-built.js baseUrl=./js

Wednesday, January 8, 14

For production you might want to bundle your files into one bundle. You still depend on require.js though. And you will have one setup for development and another one
for production.
CommonJS / Node.js

Wednesday, January 8, 14
even.js
var isEven = function(i) {
return i % 2 === 0;
};
module.exports = isEven;

Wednesday, January 8, 14
app.js
var isEven = require('./even');
console.log(1,
console.log(2,
console.log(3,
console.log(4,

Wednesday, January 8, 14

isEven(1));
isEven(2));
isEven(3));
isEven(4));
UMD
Universal Module Definition

Wednesday, January 8, 14
var shim = {};
if (typeof(exports) === 'undefined') {
if(typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
// we are in amd.
shim.exports = {};
define(function() {
return shim.exports;
});
} else {
// we are in a browser, define its namespaces in global
shim.exports = typeof(window) !== 'undefined' ? window : _global;
}
}
else {
// we are in commonjs, define its namespaces in exports
shim.exports = exports;
}

even-lib.js

(function(exports) {

var isEven = function(i) {
return i % 2 === 0;
};

if (typeof(exports) !== 'undefined') {
exports.isEven = isEven;
}
})(shim.exports);
})(this);

header.js

Wednesday, January 8, 14

This approach has been quite popular for library developers to be able to meet end users requirements.
var shim = {};
if (typeof(exports) === 'undefined') {
if(typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
// we are in amd.
shim.exports = {};
define(function() {
return shim.exports;
});
} else {
// we are in a browser, define its namespaces in global
shim.exports = typeof(window) !== 'undefined' ? window : _global;
}
}
else {
// we are in commonjs, define its namespaces in exports
shim.exports = exports;
}

even-lib.js

header.js

(function(exports) {

even.js

footer.js
header.js

var isEven = function(i) {
return i % 2 === 0;
};

if (typeof(exports) !== 'undefined') {
exports.isEven = isEven;
}
})(shim.exports);
})(this);

Wednesday, January 8, 14

This approach has been quite popular for library developers to be able to meet end users requirements.
Makefile / Build step
build:
! cat header.js even.js footer.js > even-lib.js

Wednesday, January 8, 14
ES6
export function isEven() {}
import { isEven } from 'even';

Wednesday, January 8, 14

It’s not here yet.
AMD & CommonJS

Wednesday, January 8, 14

For me, there’s really only two options here. AMD or CommonJS. Both of these solves the issue of loading modules.
Wednesday, January 8, 14

Various alternatives around for common js, as far as I know there is only require js for AMD
CommonJS

Wednesday, January 8, 14

Various alternatives around for common js, as far as I know there is only require js for AMD
CommonJS

AMD

Wednesday, January 8, 14

Various alternatives around for common js, as far as I know there is only require js for AMD
CommonJS

AMD

Wednesday, January 8, 14

Various alternatives around for common js, as far as I know there is only require js for AMD
What I want
•
•
•
•
•
Wednesday, January 8, 14

Simple
Active community
No complicated build environment
Works with existing libraries, with none or minimal adaption
Prototype friendly
require('modules') in the browser

Wednesday, January 8, 14

http://browserify.org/, substack
Demo

Wednesday, January 8, 14
Browserify
•
•
•

Wednesday, January 8, 14

require & npm modules in the browser
Browser versions of core node modules (events, stream, path, url, ...)
Extendable
How does it work?
•
•
•
•
Wednesday, January 8, 14

Small wrapper for the require function
Build process that keeps track of dependencies
Bundles to one file
No global leakage
;
(function e(t, n, r) {
function s(o, u) {
if (!n[o]) {
if (!t[o]) {
var a = typeof require == "function" && require;
if (!u && a) return a(o, !0);
if (i) return i(o, !0);
throw new Error("Cannot find module '" + o + "'")
}
var f = n[o] = {
exports: {}
};
t[o][0].call(f.exports, function (e) {
var n = t[o][1][e];
return s(n ? n : e)
}, f, f.exports, e, t, n, r)
}
return n[o].exports
}
var i = typeof require == "function" && require;
for (var o = 0; o < r.length; o++) s(r[o]);
return s
})({
1: [
function (require, module, exports) {
var isEven = function (i) {
return i % 2 === 0;
};
module.exports = isEven;
}, {}
],
2: [
function (require, module, exports) {
var isEven = require('./even');
console.log(isEven(2));
}, {
"./even": 1
}
]
}, {}, [2]);

Wednesday, January 8, 14
voxel.js
http://voxeljs.com/

Wednesday, January 8, 14
Dependencies
Package Manager
Fetch scripts, taking dependencies into account

Wednesday, January 8, 14
Current Landscape
•
•
•
•
•
•

Ender (http://ender.jit.su/)
Volo (http://volojs.org/)
Jam (http://jamjs.org/)
Bower (http://bower.io/) 7 000+
Component (http://component.io/)
npm (http://npmjs.org) 53 000+

Wednesday, January 8, 14

Quite a few alternatives around. Not likely that all of these will survive. Currently it seems like Bower is the one getting more and more attraction for front end
developers
Transformations
•
•
•
•
•

AMD via deamdify
Bower via debowerify
Global via deglobalify
ES6 via es6ify
& more

Wednesday, January 8, 14
{
"name": "bower-demo",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "Johan Nilsson",
"license": "BSD-2-Clause",
"devDependencies": {
"debowerify": "~0.5.1"
}
}

Wednesday, January 8, 14
{
"name": "bower-demo",
"main": "index.js",
"version": "0.0.0",
"authors": [
"Johan Nilsson <johan@markupartist.com>"
],
"license": "BSD-2-Clause",
"private": true,
"dependencies": {
"jquery": "~2.0.3"
}
}

Wednesday, January 8, 14
var $ = require('jquery');
$('body').append('<p>bla bla</p>');

Wednesday, January 8, 14
browserify index.js -t debowerify > bundle.js

Wednesday, January 8, 14
Additional Tools
•
•
•
•
Wednesday, January 8, 14

Watchify – Watch mode for browserify builds
Beefy – Local development server
grunt-browserify
gulp-browserify
Johan Nilsson
johan@markupartist.com
@johanni

Wednesday, January 8, 14

Weitere ähnliche Inhalte

Was ist angesagt?

Asynchronous Module Definition (AMD) used for Dependency Injection (DI) and MVVM
Asynchronous Module Definition (AMD) used for Dependency Injection (DI) and MVVMAsynchronous Module Definition (AMD) used for Dependency Injection (DI) and MVVM
Asynchronous Module Definition (AMD) used for Dependency Injection (DI) and MVVMHugh Anderson
 
uRequire@greecejs: An introduction to http://uRequire.org
uRequire@greecejs: An introduction to http://uRequire.orguRequire@greecejs: An introduction to http://uRequire.org
uRequire@greecejs: An introduction to http://uRequire.orgAgelos Pikoulas
 
Webpack Introduction
Webpack IntroductionWebpack Introduction
Webpack IntroductionAnjali Chawla
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest servicesIoan Eugen Stan
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingAndrea Giannantonio
 
Vue 淺談前端建置工具
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具andyyou
 
Webpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JSWebpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JSEmil Öberg
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS偉格 高
 
Backbone.js
Backbone.jsBackbone.js
Backbone.jsVO Tho
 
Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Spike Brehm
 
Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)xMartin12
 
JSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsJSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsSpike Brehm
 
Developing large scale JavaScript applications
Developing large scale JavaScript applicationsDeveloping large scale JavaScript applications
Developing large scale JavaScript applicationsMilan Korsos
 
Vue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thingVue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thingJoonas Lehtonen
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationDavid Amend
 

Was ist angesagt? (20)

An Intro into webpack
An Intro into webpackAn Intro into webpack
An Intro into webpack
 
RequireJS
RequireJSRequireJS
RequireJS
 
Asynchronous Module Definition (AMD) used for Dependency Injection (DI) and MVVM
Asynchronous Module Definition (AMD) used for Dependency Injection (DI) and MVVMAsynchronous Module Definition (AMD) used for Dependency Injection (DI) and MVVM
Asynchronous Module Definition (AMD) used for Dependency Injection (DI) and MVVM
 
uRequire@greecejs: An introduction to http://uRequire.org
uRequire@greecejs: An introduction to http://uRequire.orguRequire@greecejs: An introduction to http://uRequire.org
uRequire@greecejs: An introduction to http://uRequire.org
 
Webpack Introduction
Webpack IntroductionWebpack Introduction
Webpack Introduction
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side rendering
 
Vue 淺談前端建置工具
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具
 
Webpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JSWebpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JS
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)
 
Webpack
WebpackWebpack
Webpack
 
Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)
 
JSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsJSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic Apps
 
Webpack DevTalk
Webpack DevTalkWebpack DevTalk
Webpack DevTalk
 
Developing large scale JavaScript applications
Developing large scale JavaScript applicationsDeveloping large scale JavaScript applications
Developing large scale JavaScript applications
 
Vue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thingVue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thing
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
 

Andere mochten auch

CommonJSの話
CommonJSの話CommonJSの話
CommonJSの話terurou
 
Get Pumped for the HTML 5 Gamepad API
Get Pumped for the HTML 5 Gamepad APIGet Pumped for the HTML 5 Gamepad API
Get Pumped for the HTML 5 Gamepad APIKevin Whinnery
 
Web development tools { starter pack }
Web development tools { starter pack }Web development tools { starter pack }
Web development tools { starter pack }François Michaudon
 
Designing Modules for the Browser and Node with Browserify
Designing Modules for the Browser and Node with BrowserifyDesigning Modules for the Browser and Node with Browserify
Designing Modules for the Browser and Node with BrowserifyKevin Whinnery
 
npm + browserify
npm + browserifynpm + browserify
npm + browserifymaxgfeller
 
Don't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesDon't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesJamund Ferguson
 
Building testable chrome extensions
Building testable chrome extensionsBuilding testable chrome extensions
Building testable chrome extensionsSeth McLaughlin
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Ryan Weaver
 
System webpack-jspm
System webpack-jspmSystem webpack-jspm
System webpack-jspmJesse Warden
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.jsRyan Anklam
 
EMOCON 2015 - Jspm & systemjs
EMOCON 2015 - Jspm & systemjsEMOCON 2015 - Jspm & systemjs
EMOCON 2015 - Jspm & systemjs이상한모임
 
Gulp入門 - コーディングを10倍速くする
Gulp入門 - コーディングを10倍速くするGulp入門 - コーディングを10倍速くする
Gulp入門 - コーディングを10倍速くするHayashi Yuichi
 

Andere mochten auch (14)

CommonJSの話
CommonJSの話CommonJSの話
CommonJSの話
 
Get Pumped for the HTML 5 Gamepad API
Get Pumped for the HTML 5 Gamepad APIGet Pumped for the HTML 5 Gamepad API
Get Pumped for the HTML 5 Gamepad API
 
Web development tools { starter pack }
Web development tools { starter pack }Web development tools { starter pack }
Web development tools { starter pack }
 
1st npm
1st npm1st npm
1st npm
 
Designing Modules for the Browser and Node with Browserify
Designing Modules for the Browser and Node with BrowserifyDesigning Modules for the Browser and Node with Browserify
Designing Modules for the Browser and Node with Browserify
 
npm + browserify
npm + browserifynpm + browserify
npm + browserify
 
Don't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesDon't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax Trees
 
Building testable chrome extensions
Building testable chrome extensionsBuilding testable chrome extensions
Building testable chrome extensions
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
 
System webpack-jspm
System webpack-jspmSystem webpack-jspm
System webpack-jspm
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.js
 
EMOCON 2015 - Jspm & systemjs
EMOCON 2015 - Jspm & systemjsEMOCON 2015 - Jspm & systemjs
EMOCON 2015 - Jspm & systemjs
 
Gulp入門 - コーディングを10倍速くする
Gulp入門 - コーディングを10倍速くするGulp入門 - コーディングを10倍速くする
Gulp入門 - コーディングを10倍速くする
 
reveal.js 3.0.0
reveal.js 3.0.0reveal.js 3.0.0
reveal.js 3.0.0
 

Ähnlich wie JavaScript Dependencies, Modules & Browserify

Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Matt Raible
 
Introduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitIntroduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitRan Mizrahi
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppEdureka!
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang YoonJesang Yoon
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architectureJasper Moelker
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneJavascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneDeepu S Nath
 
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
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in YiiIlPeach
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]GDSC UofT Mississauga
 
Isomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassIsomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassSpike Brehm
 
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest
 
Intro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptIntro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptjasonsich
 
Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...IT Event
 
AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.Dragos Mihai Rusu
 
Dragos Rusu - Angular JS - Overcoming Performance Issues - CodeCamp-10-may-2014
Dragos Rusu  - Angular JS - Overcoming Performance Issues - CodeCamp-10-may-2014Dragos Rusu  - Angular JS - Overcoming Performance Issues - CodeCamp-10-may-2014
Dragos Rusu - Angular JS - Overcoming Performance Issues - CodeCamp-10-may-2014Codecamp Romania
 
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
 
Refactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.jsRefactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.jsStacy London
 
Refactor Large applications with Backbone
Refactor Large applications with BackboneRefactor Large applications with Backbone
Refactor Large applications with BackboneColdFusionConference
 

Ähnlich wie JavaScript Dependencies, Modules & Browserify (20)

Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
 
Introduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitIntroduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim Summit
 
Spring boot
Spring bootSpring boot
Spring boot
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoon
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architecture
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneJavascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
 
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 ...
 
Bhanu Resume
Bhanu ResumeBhanu Resume
Bhanu Resume
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in Yii
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
Isomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassIsomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master Class
 
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
 
Intro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptIntro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScript
 
Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...
 
AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.
 
Dragos Rusu - Angular JS - Overcoming Performance Issues - CodeCamp-10-may-2014
Dragos Rusu  - Angular JS - Overcoming Performance Issues - CodeCamp-10-may-2014Dragos Rusu  - Angular JS - Overcoming Performance Issues - CodeCamp-10-may-2014
Dragos Rusu - Angular JS - Overcoming Performance Issues - CodeCamp-10-may-2014
 
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...
 
Refactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.jsRefactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.js
 
Refactor Large applications with Backbone
Refactor Large applications with BackboneRefactor Large applications with Backbone
Refactor Large applications with Backbone
 

Mehr von Johan Nilsson

Utmaningar som tredjepartsutvecklare för kollektivtrafikbranchen - Kollektivt...
Utmaningar som tredjepartsutvecklare för kollektivtrafikbranchen - Kollektivt...Utmaningar som tredjepartsutvecklare för kollektivtrafikbranchen - Kollektivt...
Utmaningar som tredjepartsutvecklare för kollektivtrafikbranchen - Kollektivt...Johan Nilsson
 
GTFS & OSM in STHLM Traveling at Trafiklab
GTFS & OSM in STHLM Traveling at Trafiklab GTFS & OSM in STHLM Traveling at Trafiklab
GTFS & OSM in STHLM Traveling at Trafiklab Johan Nilsson
 
STHLM Traveling Trafiklab
STHLM Traveling TrafiklabSTHLM Traveling Trafiklab
STHLM Traveling TrafiklabJohan Nilsson
 
Spacebrew & Arduino Yún
Spacebrew & Arduino YúnSpacebrew & Arduino Yún
Spacebrew & Arduino YúnJohan Nilsson
 
Custom UI Components at Android Only 2011
Custom UI Components at Android Only 2011Custom UI Components at Android Only 2011
Custom UI Components at Android Only 2011Johan Nilsson
 
new Android UI Patterns
new Android UI Patternsnew Android UI Patterns
new Android UI PatternsJohan Nilsson
 
FOSS STHLM Android Cloud to Device Messaging
FOSS STHLM Android Cloud to Device MessagingFOSS STHLM Android Cloud to Device Messaging
FOSS STHLM Android Cloud to Device MessagingJohan Nilsson
 
Android Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG StockholmAndroid Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG StockholmJohan Nilsson
 
GTUG Android iglaset Presentation 1 Oct
GTUG Android iglaset Presentation 1 OctGTUG Android iglaset Presentation 1 Oct
GTUG Android iglaset Presentation 1 OctJohan Nilsson
 

Mehr von Johan Nilsson (11)

Utmaningar som tredjepartsutvecklare för kollektivtrafikbranchen - Kollektivt...
Utmaningar som tredjepartsutvecklare för kollektivtrafikbranchen - Kollektivt...Utmaningar som tredjepartsutvecklare för kollektivtrafikbranchen - Kollektivt...
Utmaningar som tredjepartsutvecklare för kollektivtrafikbranchen - Kollektivt...
 
GTFS & OSM in STHLM Traveling at Trafiklab
GTFS & OSM in STHLM Traveling at Trafiklab GTFS & OSM in STHLM Traveling at Trafiklab
GTFS & OSM in STHLM Traveling at Trafiklab
 
STHLM Traveling Trafiklab
STHLM Traveling TrafiklabSTHLM Traveling Trafiklab
STHLM Traveling Trafiklab
 
Spacebrew & Arduino Yún
Spacebrew & Arduino YúnSpacebrew & Arduino Yún
Spacebrew & Arduino Yún
 
Trafiklab 1206
Trafiklab 1206Trafiklab 1206
Trafiklab 1206
 
Custom UI Components at Android Only 2011
Custom UI Components at Android Only 2011Custom UI Components at Android Only 2011
Custom UI Components at Android Only 2011
 
new Android UI Patterns
new Android UI Patternsnew Android UI Patterns
new Android UI Patterns
 
FOSS STHLM Android Cloud to Device Messaging
FOSS STHLM Android Cloud to Device MessagingFOSS STHLM Android Cloud to Device Messaging
FOSS STHLM Android Cloud to Device Messaging
 
Android Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG StockholmAndroid Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG Stockholm
 
Android swedroid
Android swedroidAndroid swedroid
Android swedroid
 
GTUG Android iglaset Presentation 1 Oct
GTUG Android iglaset Presentation 1 OctGTUG Android iglaset Presentation 1 Oct
GTUG Android iglaset Presentation 1 Oct
 

Kürzlich hochgeladen

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 

Kürzlich hochgeladen (20)

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 

JavaScript Dependencies, Modules & Browserify

  • 1. Dependencies & Modules Wednesday, January 8, 14 To handle dependencies and modules in a simple way we need some proper tooling.
  • 2. Wednesday, January 8, 14 Then talk a bit about Browserify.
  • 3. Wednesday, January 8, 14 I’ve been writing JS for quite a while, then I was off doing mostly backend & Android for while. This is Theo, I felt like him here towards JS for a while I feel that the tools around for JS has increased and grown in complexity quite fast. It also feels like it is changing quite rapid. This is also what attracts me to JS, for me it feels like this is where a lot of creativity and innovation is happening. But picking the right tools is a/has been challenge.
  • 4. Web Sites vs Web Apps What’s the difference? Wednesday, January 8, 14 I find this quite interesting. And is there a difference and why do we make a difference?
  • 5. We’re all building sites that people visit, do something, and leave. Differentiating websites vs. web apps is no good to anyone. – Jack Franklin https://speakerdeck.com/jackfranklin/port80-practical-javascripting Wednesday, January 8, 14
  • 6. Why do you want to make that distinction? What benefit do you gain by arbitrarily dividing the entire web into two classes? – Jeremy Keith http://adactio.com/journal/6246/ Wednesday, January 8, 14
  • 7. A lot of people ignore new JavaScript tools, methods or approaches because those are just for “web apps.” – Jack Franklin https://speakerdeck.com/jackfranklin/port80-practical-javascripting Wednesday, January 8, 14 I’ve done this for too long.
  • 8. Dev Environment • Module System: A way to programmatically load scripts when they’re needed. • Package Manager: Fetch scripts from online sources like GitHub, taking dependencies into account. • Build Tool: Combine scripts and other assets together into something usable by browsers. http://dailyjs.com/2013/01/28/components/ Wednesday, January 8, 14 And to handle modules and dependencies properly we need to use proper tools to cope with a modern development environment
  • 9. Modules A way to programmatically load scripts when they’re needed Wednesday, January 8, 14 Let’s start with modules. What is a module? Keep it simple, it’s basically just a script that we can load whenever we need it.
  • 10. <script <script <script <script <script <script <script <script <script <script type="text/javascript" type="text/javascript" type="text/javascript" type="text/javascript" type="text/javascript" type="text/javascript" type="text/javascript" type="text/javascript" type="text/javascript" type="text/javascript" src="/js/namespace.js"></script> src="/js/vendor/buffer-loader.js"></script> src="/js/vendor/requestanimframe.js"></script> src="/js/vendor/stats.min.js"></script> src="/js/vendor/minpubsub.js"></script> src="/js/app.js"></script> src="/js/utils.js"></script> src="/js/sound.js"></script> src="/js/shape.js"></script> src="/js/main.js"></script> Wednesday, January 8, 14 We can easily do this by separating our code into various scripts. It gets a bit troublesome to manage this though. For me this way hinders me from playing around and prototyping and testing things out while developing.
  • 11. SRC_DIR = src BUILD_DIR = build JS_SERVER_FILES = $(SRC_DIR)/js/namespace.js ! $(SRC_DIR)/js/vendor/buffer-loader.js ! $(SRC_DIR)/js/vendor/requestanimframe.js ! $(SRC_DIR)/js/vendor/stats.min.js ! $(SRC_DIR)/js/vendor/minpubsub.js ! $(SRC_DIR)/js/app.js ! $(SRC_DIR)/js/utils.js ! $(SRC_DIR)/js/sound.js ! $(SRC_DIR)/js/shape.js ! $(SRC_DIR)/js/main.js JS_BUNDLE = $(BUILD_DIR)/app.js BUILD_BUNDLE = $(BUILD_DIR)/app-min.js .DEFAULT_GOAL := all all: bundle ! java -jar $(GCC_COMPRESSOR) $(GCC_OPTION) --js=$(JS_BUNDLE) -js_output_file=$(BUILD_BUNDLE) debug: bundle ! cat $(JS_FILES) >> $(JS_BUNDLE) Wednesday, January 8, 14 To assemble this for production we would need a build script. This is a Makefile from an old project of mine. Sure we can have grunt but it is still configuration clean: we need to add. ! rm -Rf $(BUILD_DIR)/* For me this isn’t really prototyping friendly.
  • 12. <% if (production) { %> <script type="text/javascript" <% } else { %> <script type="text/javascript" <script type="text/javascript" <script type="text/javascript" <script type="text/javascript" <script type="text/javascript" <script type="text/javascript" <script type="text/javascript" <script type="text/javascript" <script type="text/javascript" <script type="text/javascript" <% } %> src="/js/app-min.js"></script> src="/js/namespace.js"></script> src="/js/vendor/buffer-loader.js"></script> src="/js/vendor/requestanimframe.js"></script> src="/js/vendor/stats.min.js"></script> src="/js/vendor/minpubsub.js"></script> src="/js/app.js"></script> src="/js/utils.js"></script> src="/js/sound.js"></script> src="/js/shape.js"></script> src="/js/main.js"></script> Wednesday, January 8, 14 And we add a conditional to check if we are in production. Personally I don’t like this since it means that we’re during development will most likely run a different version of the site than we will in production.
  • 13. The Problem • • • • Code complexity grows as the site gets bigger Assembly gets harder Developer wants discrete JS files/modules Deployment wants optimized code in just one or a few HTTP calls http://requirejs.org/docs/why.html#1 Wednesday, January 8, 14 Why do we want modules. Require.JS outlines a few arguments on there website. We basically want it because we need better structure in our code.
  • 14. Current Landscape • • • • • • Globals Globals + Namespace AMD (Asynchronous Module Definition) CommonJS UMD (Universal Module Definition) (ES6) Wednesday, January 8, 14 Alternatives for modules, not taking framework specific ones like Angular into account.
  • 15. var isEven = function(i) { return i % 2 === 0; }; Wednesday, January 8, 14 I like small bits of code that can be separated and re-used. Here’s a quite simple re-usable bit of code but is short enough to fit a slide. Simple re-usable code
  • 17. even.js var isEven = function(i) { return i % 2 === 0; }; Wednesday, January 8, 14
  • 19. index.html <!doctype html> <script src="even.js"></script> <script src="app.js"></script> Wednesday, January 8, 14
  • 21. app-even.js var App = App || {}; App.isEven = function(i) { return i % 2 === 0; }; Wednesday, January 8, 14
  • 22. app.js var App = App || {}; console.log(1, console.log(2, console.log(3, console.log(4, Wednesday, January 8, 14 App.isEven(1)); App.isEven(2)); App.isEven(3)); App.isEven(4));
  • 23. index.html <!doctype html> <script src="app-even.js"></script> <script src="app.js"></script> Wednesday, January 8, 14
  • 24. AMD Asynchronous Module Definition With Require.JS Wednesday, January 8, 14
  • 25. even.js define([], function() { var isEven = function(i) { return i % 2 === 0; }; return isEven; }); Wednesday, January 8, 14
  • 26. app.js require(['even'], function(even){ console.log(1, even(1)); console.log(2, even(2)); console.log(3, even(3)); console.log(4, even(4)); }); Wednesday, January 8, 14
  • 28. //Allow for anonymous modules if (typeof name !== 'string') { //Adjust args appropriately callback = deps; deps = name; name = null; } //This module may not have dependencies if (!isArray(deps)) { callback = deps; deps = null; } require.js //If no name, and callback is a function, then figure out if it a //CommonJS thing with dependencies. if (!deps && isFunction(callback)) { deps = []; //Remove comments from the callback string, //look for require calls, and pull them into the dependencies, //but only if there are function args. if (callback.length) { callback .toString() .replace(commentRegExp, '') .replace(cjsRequireRegExp, function (match, dep) { deps.push(dep); }); //May be a CommonJS thing even without require calls, but still //could use exports, and module. Avoid doing exports and module //work though if it just needs require. //REQUIRES the function to expect the CommonJS variables in the //order listed below. deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps); } } //If in IE 6-8 and hit an anonymous define() call, do the interactive //work. if (useInteractive) { node = currentlyAddingScript || getInteractiveScript(); if (node) { if (!name) { name = node.getAttribute('data-requiremodule'); } context = contexts[node.getAttribute('data-requirecontext')]; } } //Always save off evaluating the def call until the script onload handler. //This allows multiple modules to be in a file without prematurely //tracing dependencies, and allows for anonymous module support, //where the module name is not known until the script onload event //occurs. If no context, use the global queue, and get it processed //in the onscript load callback. (context ? context.defQueue : globalDefQueue).push([name, deps, callback]); }; define.amd = { jQuery: true }; Wednesday, January 8, 14 /** * Executes the text. Normally just uses eval, but can be modified * to use a better, environment-specific call. Only used for transpiling * loader plugins, not for plain JS modules. * @param {String} text the text to execute/evaluate. */ req.exec = function (text) { /*jslint evil: true */ return eval(text); }; Quite a massive file that is required //Set load these files. Not sure exactly what goes on here, but it works. to up with config info. req(cfg); }(this));
  • 29. Makefile / Build step build: ! node r.js -o name=app out=js/app-built.js baseUrl=./js build-even: ! node r.js -o name=even out=js/even-built.js baseUrl=./js Wednesday, January 8, 14 For production you might want to bundle your files into one bundle. You still depend on require.js though. And you will have one setup for development and another one for production.
  • 31. even.js var isEven = function(i) { return i % 2 === 0; }; module.exports = isEven; Wednesday, January 8, 14
  • 32. app.js var isEven = require('./even'); console.log(1, console.log(2, console.log(3, console.log(4, Wednesday, January 8, 14 isEven(1)); isEven(2)); isEven(3)); isEven(4));
  • 34. var shim = {}; if (typeof(exports) === 'undefined') { if(typeof define == 'function' && typeof define.amd == 'object' && define.amd) { // we are in amd. shim.exports = {}; define(function() { return shim.exports; }); } else { // we are in a browser, define its namespaces in global shim.exports = typeof(window) !== 'undefined' ? window : _global; } } else { // we are in commonjs, define its namespaces in exports shim.exports = exports; } even-lib.js (function(exports) { var isEven = function(i) { return i % 2 === 0; }; if (typeof(exports) !== 'undefined') { exports.isEven = isEven; } })(shim.exports); })(this); header.js Wednesday, January 8, 14 This approach has been quite popular for library developers to be able to meet end users requirements.
  • 35. var shim = {}; if (typeof(exports) === 'undefined') { if(typeof define == 'function' && typeof define.amd == 'object' && define.amd) { // we are in amd. shim.exports = {}; define(function() { return shim.exports; }); } else { // we are in a browser, define its namespaces in global shim.exports = typeof(window) !== 'undefined' ? window : _global; } } else { // we are in commonjs, define its namespaces in exports shim.exports = exports; } even-lib.js header.js (function(exports) { even.js footer.js header.js var isEven = function(i) { return i % 2 === 0; }; if (typeof(exports) !== 'undefined') { exports.isEven = isEven; } })(shim.exports); })(this); Wednesday, January 8, 14 This approach has been quite popular for library developers to be able to meet end users requirements.
  • 36. Makefile / Build step build: ! cat header.js even.js footer.js > even-lib.js Wednesday, January 8, 14
  • 37. ES6 export function isEven() {} import { isEven } from 'even'; Wednesday, January 8, 14 It’s not here yet.
  • 38. AMD & CommonJS Wednesday, January 8, 14 For me, there’s really only two options here. AMD or CommonJS. Both of these solves the issue of loading modules.
  • 39. Wednesday, January 8, 14 Various alternatives around for common js, as far as I know there is only require js for AMD
  • 40. CommonJS Wednesday, January 8, 14 Various alternatives around for common js, as far as I know there is only require js for AMD
  • 41. CommonJS AMD Wednesday, January 8, 14 Various alternatives around for common js, as far as I know there is only require js for AMD
  • 42. CommonJS AMD Wednesday, January 8, 14 Various alternatives around for common js, as far as I know there is only require js for AMD
  • 43. What I want • • • • • Wednesday, January 8, 14 Simple Active community No complicated build environment Works with existing libraries, with none or minimal adaption Prototype friendly
  • 44. require('modules') in the browser Wednesday, January 8, 14 http://browserify.org/, substack
  • 46. Browserify • • • Wednesday, January 8, 14 require & npm modules in the browser Browser versions of core node modules (events, stream, path, url, ...) Extendable
  • 47. How does it work? • • • • Wednesday, January 8, 14 Small wrapper for the require function Build process that keeps track of dependencies Bundles to one file No global leakage
  • 48. ; (function e(t, n, r) { function s(o, u) { if (!n[o]) { if (!t[o]) { var a = typeof require == "function" && require; if (!u && a) return a(o, !0); if (i) return i(o, !0); throw new Error("Cannot find module '" + o + "'") } var f = n[o] = { exports: {} }; t[o][0].call(f.exports, function (e) { var n = t[o][1][e]; return s(n ? n : e) }, f, f.exports, e, t, n, r) } return n[o].exports } var i = typeof require == "function" && require; for (var o = 0; o < r.length; o++) s(r[o]); return s })({ 1: [ function (require, module, exports) { var isEven = function (i) { return i % 2 === 0; }; module.exports = isEven; }, {} ], 2: [ function (require, module, exports) { var isEven = require('./even'); console.log(isEven(2)); }, { "./even": 1 } ] }, {}, [2]); Wednesday, January 8, 14
  • 50. Dependencies Package Manager Fetch scripts, taking dependencies into account Wednesday, January 8, 14
  • 51. Current Landscape • • • • • • Ender (http://ender.jit.su/) Volo (http://volojs.org/) Jam (http://jamjs.org/) Bower (http://bower.io/) 7 000+ Component (http://component.io/) npm (http://npmjs.org) 53 000+ Wednesday, January 8, 14 Quite a few alternatives around. Not likely that all of these will survive. Currently it seems like Bower is the one getting more and more attraction for front end developers
  • 52. Transformations • • • • • AMD via deamdify Bower via debowerify Global via deglobalify ES6 via es6ify & more Wednesday, January 8, 14
  • 53. { "name": "bower-demo", "version": "0.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo "Error: no test specified" && exit 1" }, "author": "Johan Nilsson", "license": "BSD-2-Clause", "devDependencies": { "debowerify": "~0.5.1" } } Wednesday, January 8, 14
  • 54. { "name": "bower-demo", "main": "index.js", "version": "0.0.0", "authors": [ "Johan Nilsson <johan@markupartist.com>" ], "license": "BSD-2-Clause", "private": true, "dependencies": { "jquery": "~2.0.3" } } Wednesday, January 8, 14
  • 55. var $ = require('jquery'); $('body').append('<p>bla bla</p>'); Wednesday, January 8, 14
  • 56. browserify index.js -t debowerify > bundle.js Wednesday, January 8, 14
  • 57. Additional Tools • • • • Wednesday, January 8, 14 Watchify – Watch mode for browserify builds Beefy – Local development server grunt-browserify gulp-browserify