SlideShare a Scribd company logo
1 of 32
A Few Good JavaScript
Development Tools
Jul. 12 2016 Simon Kim
NexStreaming Corp.
Agenda
ECMAScript 6 - JavaScript Languages
Visual Studio Code - Editors or IDE
Node.js & npm - All Time Friends
webpack, Babel, UglifyJS - Build
Jasmine - Testing
Chrome Developer Tools - Debugging
YUIDoc - Documentation
Agenda
ECMAScript 6 - JavaScript Languages
Visual Studio Code - Editors or IDE
Node.js & npm - All Time Friends
webpack, Babel, UglifyJS - Build
Jasmine - Testing
Chrome Developer Tools - Debugging
YUIDoc - Documentation
Code
Build
Test
Debug
Document
Demo Project: https://github.com/simonkim/jstools-demo
JavaScript Language
ECMA-262 Specification
First Edition - June 1997
...
ECMAScript 5.1 Edition - June 2011
ECMAScript 6th Edition (ECMAScript 2015) - June 2015
ES6, ES2015
Misc.
CoffeeScript - http://coffeescript.org
JavaScript Language - ECMAScript 6
// ECMAScript 5
var Shape = function (id, x, y) {
this.id = id;
this.move(x, y);
};
Shape.prototype.move = function (x, y) {
this.x = x;
this.y = y;
};
// ECMAScript 6
class Shape {
constructor (id, x, y) {
this.id = id
this.move(x, y)
}
move (x, y) {
this.x = x
this.y = y
}
}
See http://es6-features.org for Details
Editors or IDEs
IDEs
WebStrom - JetBrains https://www.jetbrains.com/webstorm/ - $$$
Eclips IDE for JavaScript Web Developers - https://eclips.org - $$$
Aptana Studio 3 - http://www.aptana.com - $$$
Editors
Sublime Text - http://www.sublimetext.com - $
Atom - https://atom.io
Visual Studio Code - https://code.visualstudio.com/
Visual Studio Code
Node.js & npm
Node.js - https://nodejs.org/
JavaScript Runtime Built on Chrome’s V8 JavaScript Engine
Event Driven
Non-Blocking IO Model
npm - https://www.npmjs.com
Package Manager for JavaScript
Share and Reuse Node.js Modules
$ npm install express
# To publish
$ npm login
$ npm publish
npm - Example Node.js Module
See Using a package.json for Details
// package.json
{
"name": "mymodule",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified"
&& exit 1",
},
"author": "",
"license": "ISC"
}
// index.js
function Mymodule() {
}
Mymodule.prototype.hello = function() {
console.log(“Hello, Node.js module”);
}
module.exports = Mymodule;
// sample.js
Mymodule = require(‘./index’);
var mymodule = new MyModule();
mymodule.hello();
// Hello, Node.js module
Build
JavaScript is Interpreter Language, Why Build?
Bundle Multiple Modules into Single .JS File
<script src=”app.bundle.js” />
Transpile
Write in ES6, CoffeeScript, or TypeScript
Run Browser Compatible Version of JavaScript
Minimization and Obfuscation
The Smaller, The Faster Loading
Hard to Read Source
Build
GRUNT - http://gruntjs.com
A JavaScript task runner for automation configured in Gruntfile
gulp.js - http://gulpjs.com
Streaming build system runs tasks defined in gulpfile.js
Browserify - http://browserify.org
Bundle node modules to allow running in browsers
webpack - https://webpack.github.io
A module bundler: takes modules with dependencies and generates static assets
Build - webpack
Build - webpack
$ npm install webpack -g
$ webpack ./app.js app.bundle.js
http://webpack.github.io/docs/usage.html
Build - JavaScript in Web Browser
<body>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jque
ry.min.js"></script>
<div id="content">
<textarea id="input" rows=4 cols=80></textarea>
<button id="convert">Submit</button>
<p id="output"></p>
</div>
<script type="text/javascript">
$('#convert').click(function(e) {
var text = $('#input').val();
$( '#output' ).html( '<p>' + text + '</p>' );
});
</script>
</body>
Sample: https://jsfiddle.net/yd2517e4/
// webpack.config.js
module.exports = {
output.library: “Hlsm3u8”
}
Build - Node Module in Web Browser
<body>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jque
ry.min.js"></script>
<script src="scripts/app.bundle.js"></script>
<div id="content">
<textarea id="input" rows=4 cols=80></textarea>
<button id="convert">Submit</button>
<p id="output"></p>
</div>
<script type="text/javascript">
$('#convert').click(function(e) {
var text = $('#input').val();
var hlsm3u8 = new Hlsm3u8();
text = hlsm3u8.parse(text);
$( '#output' ).html( '<p>' + text + '</p>' );
});
</script>
</body>
‘output.library’ option of ‘webpack’
enables access to node module
exports from browser code
Build - Transpile
CoffeeScript - http://coffeescript.org
TypeScript - https://www.typescriptlang.org
Babel - https://babeljs.io
A JavaScript Compiler
ECPAScript 2015 ( ES6 ) to Browser Compatible JavaScript (? TBC)
// output.js
'use strict';
var _createClass = function () { //... }();
function _classCallCheck(instance, Constructor) { //... }
var Sample = function () {
function Sample(text) {
_classCallCheck(this, Sample);
this.text = text;
}
_createClass(Sample, [{
key: 'printHello',
value: function printHello() {
console.log('hello ' + this.text);
}
}]);
return Sample;
}();
var sample = new Sample('Babel');
sample.printHello();
Babel - Example
// sample.js
class Sample {
constructor(text) { this.text = text; }
printHello() { console.log(`hello ${this.text}`); }
}
var sample = new Sample('Babel');
sample.printHello();
// .babelrc
{
presets: [“es2015”]
}
# Install babel and transpile
$ npm install --save-dev babel-cli babel-preset-
es2015
$ ./node_modules/.bin/babel sample.js >
output.js
Build - Babel with webpack
Install Node Modules
$ npm install --save-dev babel-loader babel-core
Configure webpack
// webpack.config.js
module: {
loaders: [
{ test: /.js$/, exclude: /node_modules/, loader:
"babel-loader" }
]
}
Configure Babel: .babelrc
{
"presets": ["es2015"]
}
See https://babeljs.io/docs/setup/#installation for
Details
Build - Minimization and Obfuscation
minifier - https://www.npmjs.com/package/minifier
YUI Compressor - http://yui.github.io/yuicompressor/
UglifyJS2 - https://github.com/mishoo/UglifyJS2
Build - UglifyJS2 Example
# Install UglifyJS2
$ npm install uglify-js -g
$ uglifyjs input.js --compress --mangle -o
ouput.js
// output.js
"use strict";function _classCallCheck(e,n){if(!(e instanceof n))throw new
TypeError("Cannot call a class as a function")}var
_createClass=function(){function e(e,n){for(var t=0;t<n.length;t++){var
l=n[t];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in
l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}return
function(n,t,l){return
t&&e(n.prototype,t),l&&e(n,l),n}}(),Sample=function(){function
e(n){_classCallCheck(this,e),this.text=n}return
_createClass(e,[{key:"printHello",value:function(){console.log("hello
"+this.text)}}]),e}(),sample=new Sample("Babel");sample.printHello();
// input.js
'use strict';
var _createClass = function () { //... }();
function _classCallCheck(instance, Constructor) { //... }
var Sample = function () {
function Sample(text) {
_classCallCheck(this, Sample);
this.text = text;
}
_createClass(Sample, [{
key: 'printHello',
value: function printHello() {
console.log('hello ' + this.text);
}
}]);
return Sample;
}();
var sample = new Sample('Babel');
sample.printHello();
Build - UglifyJS with webpack
webpack UglifyJSPlugin
http://webpack.github.io/docs/list-of-
plugins.html#uglifyjsplugin
$ npm install webpack --save-dev
// webpack.config.js
module.exports = {
...
plugins:[new webpack.optimize.UglifyJsPlugin({
compress: {warnings: false},
})]
…
}
$ webpack
Testing
Jasmine - http://jasmine.github.io
“Jasmine is a behavior-driven development framework for testing JavaScript code.”
Karma - https://karma-runner.github.io/
Test Runner. Unit Testing.
And Many Others.
Testing - Jasmine
Install ‘jasmine’ command
$ npm install -g jasmine
Create jasmine.json, default
configuration
$ jasmine init
Write test cases, jasmine specs, and
run
$ jasmine
// myappSpec.js
describe("A suite", function() {
it("contains spec with an expectation",
function() {
expect(true).toBe(true);
});
it("The 'toBeLessThan' matcher is for
mathematical comparisons", function() {
var pi = 3.1415926,
e = 2.78;
expect(e).toBeLessThan(pi);
expect(pi).not.toBeLessThan(e);
});
});
Running Tests in a Browser
In HTML, include source and spec files and jasmine files
Open the HTML File in Browser
Testing - Jasmine
<link rel="shortcut icon" type="image/png"
href="lib/jasmine-2.4.1/jasmine_favicon.png">
<link rel="stylesheet" href="lib/jasmine-
2.4.1/jasmine.css">
<script src="lib/jasmine-
2.4.1/jasmine.js"></script>
<script src="lib/jasmine-2.4.1/jasmine-
html.js"></script>
<script src="lib/jasmine-
2.4.1/boot.js"></script>
<!-- include source files here... -->
<script
src="../public/dist/hlsm3u8.js"></script>
<!-- include spec files here... -->
<script
src="../spec/hlsm3u8spec.js"></script>
Chrome Developer Tools - https://developers.google.com/web/tools/chrome-devtools/
Chrome -> Menu -> View -> Developers -> Developer Tools
Source Map
Maps combined/minified file back to an unbuilt state
Debugging
Debugging - Chrome Developer Tools
Debugging - Source Map
Without Source Map
Debugging - Source Map
With Source Map
Debugging - Source Map
Introduction to JavaScript Source Map
Generating Source Map with webpack Build
$ webpack -d
app.bundle.js
app.bundle.js.map
See Development shortcut -d and devtool Webpack configuration for Details
Chrome DevTools Locates Source Map (.map) in the Same Path of .JS
Documentation
JSDoc - http://usejsdoc.org
Docco - https://jashkenas.github.io/docco/
YUIDoc - http://yui.github.io/yuidoc/
Documentation - YUIDoc
# Install babel and transpile
$ npm install -g yuidocjs
$ yuidoc .
$ # open out/index.html in browser
Summary
Code BuildTestDebug Document
+ Source Map
Demo Project:
https://github.com/simonkim/jstools-demo

More Related Content

What's hot

Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Paulo Ragonha
 
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Fwdays
 
Metaprogramming 101
Metaprogramming 101Metaprogramming 101
Metaprogramming 101
Nando Vieira
 

What's hot (20)

Testing frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabsTesting frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabs
 
Django for mobile applications
Django for mobile applicationsDjango for mobile applications
Django for mobile applications
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
20160905 - BrisJS - nightwatch testing
20160905 - BrisJS - nightwatch testing20160905 - BrisJS - nightwatch testing
20160905 - BrisJS - nightwatch testing
 
React Native in Production
React Native in ProductionReact Native in Production
React Native in Production
 
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
 
JavaFX – 10 things I love about you
JavaFX – 10 things I love about youJavaFX – 10 things I love about you
JavaFX – 10 things I love about you
 
The JavaFX Ecosystem
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX Ecosystem
 
Metaprogramming 101
Metaprogramming 101Metaprogramming 101
Metaprogramming 101
 
Building a Startup Stack with AngularJS
Building a Startup Stack with AngularJSBuilding a Startup Stack with AngularJS
Building a Startup Stack with AngularJS
 
The DOM is a Mess @ Yahoo
The DOM is a Mess @ YahooThe DOM is a Mess @ Yahoo
The DOM is a Mess @ Yahoo
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with Jest
 
JavaOne - The JavaFX Community and Ecosystem
JavaOne - The JavaFX Community and EcosystemJavaOne - The JavaFX Community and Ecosystem
JavaOne - The JavaFX Community and Ecosystem
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
 
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey BuzdinMarvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
 
From Swing to JavaFX
From Swing to JavaFXFrom Swing to JavaFX
From Swing to JavaFX
 
Testing JS with Jasmine
Testing JS with JasmineTesting JS with Jasmine
Testing JS with Jasmine
 
Vuejs testing
Vuejs testingVuejs testing
Vuejs testing
 
Code ceptioninstallation
Code ceptioninstallationCode ceptioninstallation
Code ceptioninstallation
 
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
 

Viewers also liked

UglifyJS 使用文档
UglifyJS 使用文档UglifyJS 使用文档
UglifyJS 使用文档
明 李
 
Debugging tools in web browsers
Debugging tools in web browsersDebugging tools in web browsers
Debugging tools in web browsers
Sarah Dutkiewicz
 

Viewers also liked (7)

UglifyJS 使用文档
UglifyJS 使用文档UglifyJS 使用文档
UglifyJS 使用文档
 
Debugging Javascript
Debugging JavascriptDebugging Javascript
Debugging Javascript
 
Debugging tools in web browsers
Debugging tools in web browsersDebugging tools in web browsers
Debugging tools in web browsers
 
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
 
Tools and Techniques for Faster Development
Tools and Techniques for Faster DevelopmentTools and Techniques for Faster Development
Tools and Techniques for Faster Development
 
Finding and debugging memory leaks in JavaScript with Chrome DevTools
Finding and debugging memory leaks in JavaScript with Chrome DevToolsFinding and debugging memory leaks in JavaScript with Chrome DevTools
Finding and debugging memory leaks in JavaScript with Chrome DevTools
 

Similar to A few good JavaScript development tools

[Strukelj] Why will Java 7.0 be so cool
[Strukelj] Why will Java 7.0 be so cool[Strukelj] Why will Java 7.0 be so cool
[Strukelj] Why will Java 7.0 be so cool
javablend
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
Andy Peterson
 

Similar to A few good JavaScript development tools (20)

Xopus Application Framework
Xopus Application FrameworkXopus Application Framework
Xopus Application Framework
 
Angular JS in 2017
Angular JS in 2017Angular JS in 2017
Angular JS in 2017
 
Lecture: Webpack 4
Lecture: Webpack 4Lecture: Webpack 4
Lecture: Webpack 4
 
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
 
Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of us
 
Npm scripts
Npm scriptsNpm scripts
Npm scripts
 
Webpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoWebpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San Francisco
 
Reliable Javascript
Reliable Javascript Reliable Javascript
Reliable Javascript
 
(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us
 
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...
 
[Strukelj] Why will Java 7.0 be so cool
[Strukelj] Why will Java 7.0 be so cool[Strukelj] Why will Java 7.0 be so cool
[Strukelj] Why will Java 7.0 be so cool
 
May The Nodejs Be With You
May The Nodejs Be With YouMay The Nodejs Be With You
May The Nodejs Be With You
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
Code Splitting in Practice - Shanghai JS Meetup May 2016
Code Splitting in Practice - Shanghai JS Meetup May 2016Code Splitting in Practice - Shanghai JS Meetup May 2016
Code Splitting in Practice - Shanghai JS Meetup May 2016
 
Workflow para desenvolvimento Web & Mobile usando grunt.js
Workflow para desenvolvimento Web & Mobile usando grunt.jsWorkflow para desenvolvimento Web & Mobile usando grunt.js
Workflow para desenvolvimento Web & Mobile usando grunt.js
 
Intro to ES6 and why should you bother !
Intro to ES6 and why should you bother !Intro to ES6 and why should you bother !
Intro to ES6 and why should you bother !
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
 
How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?
 

Recently uploaded

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 

Recently uploaded (20)

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using PipesLinux Systems Programming: Inter Process Communication (IPC) using Pipes
Linux Systems Programming: Inter Process Communication (IPC) using Pipes
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .ppt
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
👉 Yavatmal Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl S...
👉 Yavatmal Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl S...👉 Yavatmal Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl S...
👉 Yavatmal Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top Class Call Girl S...
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Introduction to Geographic Information Systems
Introduction to Geographic Information SystemsIntroduction to Geographic Information Systems
Introduction to Geographic Information Systems
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
 
Introduction to Artificial Intelligence ( AI)
Introduction to Artificial Intelligence ( AI)Introduction to Artificial Intelligence ( AI)
Introduction to Artificial Intelligence ( AI)
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Memory Interfacing of 8086 with DMA 8257
Memory Interfacing of 8086 with DMA 8257Memory Interfacing of 8086 with DMA 8257
Memory Interfacing of 8086 with DMA 8257
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 

A few good JavaScript development tools

  • 1. A Few Good JavaScript Development Tools Jul. 12 2016 Simon Kim NexStreaming Corp.
  • 2. Agenda ECMAScript 6 - JavaScript Languages Visual Studio Code - Editors or IDE Node.js & npm - All Time Friends webpack, Babel, UglifyJS - Build Jasmine - Testing Chrome Developer Tools - Debugging YUIDoc - Documentation
  • 3. Agenda ECMAScript 6 - JavaScript Languages Visual Studio Code - Editors or IDE Node.js & npm - All Time Friends webpack, Babel, UglifyJS - Build Jasmine - Testing Chrome Developer Tools - Debugging YUIDoc - Documentation Code Build Test Debug Document Demo Project: https://github.com/simonkim/jstools-demo
  • 4. JavaScript Language ECMA-262 Specification First Edition - June 1997 ... ECMAScript 5.1 Edition - June 2011 ECMAScript 6th Edition (ECMAScript 2015) - June 2015 ES6, ES2015 Misc. CoffeeScript - http://coffeescript.org
  • 5. JavaScript Language - ECMAScript 6 // ECMAScript 5 var Shape = function (id, x, y) { this.id = id; this.move(x, y); }; Shape.prototype.move = function (x, y) { this.x = x; this.y = y; }; // ECMAScript 6 class Shape { constructor (id, x, y) { this.id = id this.move(x, y) } move (x, y) { this.x = x this.y = y } } See http://es6-features.org for Details
  • 6. Editors or IDEs IDEs WebStrom - JetBrains https://www.jetbrains.com/webstorm/ - $$$ Eclips IDE for JavaScript Web Developers - https://eclips.org - $$$ Aptana Studio 3 - http://www.aptana.com - $$$ Editors Sublime Text - http://www.sublimetext.com - $ Atom - https://atom.io Visual Studio Code - https://code.visualstudio.com/
  • 8. Node.js & npm Node.js - https://nodejs.org/ JavaScript Runtime Built on Chrome’s V8 JavaScript Engine Event Driven Non-Blocking IO Model npm - https://www.npmjs.com Package Manager for JavaScript Share and Reuse Node.js Modules $ npm install express
  • 9. # To publish $ npm login $ npm publish npm - Example Node.js Module See Using a package.json for Details // package.json { "name": "mymodule", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo "Error: no test specified" && exit 1", }, "author": "", "license": "ISC" } // index.js function Mymodule() { } Mymodule.prototype.hello = function() { console.log(“Hello, Node.js module”); } module.exports = Mymodule; // sample.js Mymodule = require(‘./index’); var mymodule = new MyModule(); mymodule.hello(); // Hello, Node.js module
  • 10. Build JavaScript is Interpreter Language, Why Build? Bundle Multiple Modules into Single .JS File <script src=”app.bundle.js” /> Transpile Write in ES6, CoffeeScript, or TypeScript Run Browser Compatible Version of JavaScript Minimization and Obfuscation The Smaller, The Faster Loading Hard to Read Source
  • 11. Build GRUNT - http://gruntjs.com A JavaScript task runner for automation configured in Gruntfile gulp.js - http://gulpjs.com Streaming build system runs tasks defined in gulpfile.js Browserify - http://browserify.org Bundle node modules to allow running in browsers webpack - https://webpack.github.io A module bundler: takes modules with dependencies and generates static assets
  • 13. Build - webpack $ npm install webpack -g $ webpack ./app.js app.bundle.js http://webpack.github.io/docs/usage.html
  • 14. Build - JavaScript in Web Browser <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jque ry.min.js"></script> <div id="content"> <textarea id="input" rows=4 cols=80></textarea> <button id="convert">Submit</button> <p id="output"></p> </div> <script type="text/javascript"> $('#convert').click(function(e) { var text = $('#input').val(); $( '#output' ).html( '<p>' + text + '</p>' ); }); </script> </body> Sample: https://jsfiddle.net/yd2517e4/
  • 15. // webpack.config.js module.exports = { output.library: “Hlsm3u8” } Build - Node Module in Web Browser <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jque ry.min.js"></script> <script src="scripts/app.bundle.js"></script> <div id="content"> <textarea id="input" rows=4 cols=80></textarea> <button id="convert">Submit</button> <p id="output"></p> </div> <script type="text/javascript"> $('#convert').click(function(e) { var text = $('#input').val(); var hlsm3u8 = new Hlsm3u8(); text = hlsm3u8.parse(text); $( '#output' ).html( '<p>' + text + '</p>' ); }); </script> </body> ‘output.library’ option of ‘webpack’ enables access to node module exports from browser code
  • 16. Build - Transpile CoffeeScript - http://coffeescript.org TypeScript - https://www.typescriptlang.org Babel - https://babeljs.io A JavaScript Compiler ECPAScript 2015 ( ES6 ) to Browser Compatible JavaScript (? TBC)
  • 17. // output.js 'use strict'; var _createClass = function () { //... }(); function _classCallCheck(instance, Constructor) { //... } var Sample = function () { function Sample(text) { _classCallCheck(this, Sample); this.text = text; } _createClass(Sample, [{ key: 'printHello', value: function printHello() { console.log('hello ' + this.text); } }]); return Sample; }(); var sample = new Sample('Babel'); sample.printHello(); Babel - Example // sample.js class Sample { constructor(text) { this.text = text; } printHello() { console.log(`hello ${this.text}`); } } var sample = new Sample('Babel'); sample.printHello(); // .babelrc { presets: [“es2015”] } # Install babel and transpile $ npm install --save-dev babel-cli babel-preset- es2015 $ ./node_modules/.bin/babel sample.js > output.js
  • 18. Build - Babel with webpack Install Node Modules $ npm install --save-dev babel-loader babel-core Configure webpack // webpack.config.js module: { loaders: [ { test: /.js$/, exclude: /node_modules/, loader: "babel-loader" } ] } Configure Babel: .babelrc { "presets": ["es2015"] } See https://babeljs.io/docs/setup/#installation for Details
  • 19. Build - Minimization and Obfuscation minifier - https://www.npmjs.com/package/minifier YUI Compressor - http://yui.github.io/yuicompressor/ UglifyJS2 - https://github.com/mishoo/UglifyJS2
  • 20. Build - UglifyJS2 Example # Install UglifyJS2 $ npm install uglify-js -g $ uglifyjs input.js --compress --mangle -o ouput.js // output.js "use strict";function _classCallCheck(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,n){for(var t=0;t<n.length;t++){var l=n[t];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}return function(n,t,l){return t&&e(n.prototype,t),l&&e(n,l),n}}(),Sample=function(){function e(n){_classCallCheck(this,e),this.text=n}return _createClass(e,[{key:"printHello",value:function(){console.log("hello "+this.text)}}]),e}(),sample=new Sample("Babel");sample.printHello(); // input.js 'use strict'; var _createClass = function () { //... }(); function _classCallCheck(instance, Constructor) { //... } var Sample = function () { function Sample(text) { _classCallCheck(this, Sample); this.text = text; } _createClass(Sample, [{ key: 'printHello', value: function printHello() { console.log('hello ' + this.text); } }]); return Sample; }(); var sample = new Sample('Babel'); sample.printHello();
  • 21. Build - UglifyJS with webpack webpack UglifyJSPlugin http://webpack.github.io/docs/list-of- plugins.html#uglifyjsplugin $ npm install webpack --save-dev // webpack.config.js module.exports = { ... plugins:[new webpack.optimize.UglifyJsPlugin({ compress: {warnings: false}, })] … } $ webpack
  • 22. Testing Jasmine - http://jasmine.github.io “Jasmine is a behavior-driven development framework for testing JavaScript code.” Karma - https://karma-runner.github.io/ Test Runner. Unit Testing. And Many Others.
  • 23. Testing - Jasmine Install ‘jasmine’ command $ npm install -g jasmine Create jasmine.json, default configuration $ jasmine init Write test cases, jasmine specs, and run $ jasmine // myappSpec.js describe("A suite", function() { it("contains spec with an expectation", function() { expect(true).toBe(true); }); it("The 'toBeLessThan' matcher is for mathematical comparisons", function() { var pi = 3.1415926, e = 2.78; expect(e).toBeLessThan(pi); expect(pi).not.toBeLessThan(e); }); });
  • 24. Running Tests in a Browser In HTML, include source and spec files and jasmine files Open the HTML File in Browser Testing - Jasmine <link rel="shortcut icon" type="image/png" href="lib/jasmine-2.4.1/jasmine_favicon.png"> <link rel="stylesheet" href="lib/jasmine- 2.4.1/jasmine.css"> <script src="lib/jasmine- 2.4.1/jasmine.js"></script> <script src="lib/jasmine-2.4.1/jasmine- html.js"></script> <script src="lib/jasmine- 2.4.1/boot.js"></script> <!-- include source files here... --> <script src="../public/dist/hlsm3u8.js"></script> <!-- include spec files here... --> <script src="../spec/hlsm3u8spec.js"></script>
  • 25. Chrome Developer Tools - https://developers.google.com/web/tools/chrome-devtools/ Chrome -> Menu -> View -> Developers -> Developer Tools Source Map Maps combined/minified file back to an unbuilt state Debugging
  • 26. Debugging - Chrome Developer Tools
  • 27. Debugging - Source Map Without Source Map
  • 28. Debugging - Source Map With Source Map
  • 29. Debugging - Source Map Introduction to JavaScript Source Map Generating Source Map with webpack Build $ webpack -d app.bundle.js app.bundle.js.map See Development shortcut -d and devtool Webpack configuration for Details Chrome DevTools Locates Source Map (.map) in the Same Path of .JS
  • 30. Documentation JSDoc - http://usejsdoc.org Docco - https://jashkenas.github.io/docco/ YUIDoc - http://yui.github.io/yuidoc/
  • 31. Documentation - YUIDoc # Install babel and transpile $ npm install -g yuidocjs $ yuidoc . $ # open out/index.html in browser
  • 32. Summary Code BuildTestDebug Document + Source Map Demo Project: https://github.com/simonkim/jstools-demo