SlideShare a Scribd company logo
JavaScript. High Performance
      Applications

                    21/03/12
                  Dev-Pro. net


                                 1
Javascript. What is it?
•   Everything is a object
•   Class free
•   Typeless syntax
•   No compilation
•   C-like syntax




                                     2
Patterns


General solution to a commonly
  occurring problem. Optimal
 solution to common problem




                                 3
Live design patterns demonstration:
•   Singleton
•   Module
•   Prototype
•   Factory
•   Decorator




                                          4
for loop research




                    5
Local Storage performance

<script>
localStorage.clear();

for(var i = 0; i < 100; i++)
 localStorage.setItem(i, 'Value ' + i);
</script>




                                          6
Jquery VS yourself code




                          7
Jquery VS yourself code




                          8
Node Storage




               9
Node Storage




               10
Regular expressions
<div id="foo" class="a foo bar"></div>
<script>
 Benchmark.prototype.setup = function() {
  var r;
  var element = document.getElementById('foo');
  var reContains = /(?:^| )foo(?: |$)/;

  function dynamicRegExp(node) {
    return RegExp('(?:^| )foo(?: |$)').test(node.className);
  }

  function inlineRegExp(node) {
    return /(?:^| )foo(?: |$)/.test(node.className);
  }

  function storedRegExp(node) {
    return reContains.test(node.className);
  }

  function stringIndexOf(node) {
    return (' ' + node.className + ' ').indexOf(' foo ') > -1;
  }


 };
</script>




                                                                 11
Regular expressions




                      12
prototype chain lookup, cached or not

<script>
 if (!Object.create) {
  Object.create = function(o) {
   function F() {}
   F.prototype = o;
   return new F();
  };}
    var foo = {
  fun: "weee!"
 },
     bar = Object.create(foo),
     baz = Object.create(bar),
     _fun = baz.fun,
     res;
</script>




                                                       13
prototype chain lookup, cached or not




                                        14
Operations which require an implicit primitive-to-
     object cast/conversion will be slower.




                                                     15
Operations which require an implicit primitive-to-
     object cast/conversion will be slower.




                                                     16
undefined void 0 perf
<script>
var undefined;
</script>
<script>
 Benchmark.prototype.setup = function() {
  var r;
  var u;
  var u2;

  var useVoid = function(a) {
   return (a === void 0);
  };

  var useGlobalUndefined = function(a) {
   return (a === undefined);
  };

  var useLocalUndefined = function(a) {
   return (a === u2);
  };

  var useTypeOfUndefined = function(a) {
    return typeof a === 'undefined';
  };
 };
</script>
                                                                    17
undefined void 0 perf




                        18
Switch vs If




               19
JavaScript Unit testing
Jasmine is a behavior-driven development framework for
testing your JavaScript code. It does not depend on any other
JavaScript frameworks. It does not require a DOM. And it has
a clean, obvious syntax so that you can easily write tests.




                                                           20
Jasmine

describe("isLeapYear", function() {
it("2004 should be leap year", function() {
          expect(isLeapYear(2004)).toBeTruthy();
          expect(isLeapYear(2004)).toEqual(true);
           });




                                                    21
Jasmine Matchers




                   22
JS-test Driver




                 23
JS-test Driver




                 24
JS test driver




                 25
YUI test framework




                     26
YUI test framework. Examples




                               27
BUILDING
 NATIVE APPS WITH
Titanium Mobile


                    28
What if you could create
apps using JavaScript?




                           29
Titanium Mobile

                  30
Titanium Mobile
Build Fully Native iPhone Apps




                                 31
32
JavaScript on the the sofa




                             33
34
35
36
JS & Gradle
assembly, minimizing, deploy




                               37
Why do I need automatic assembly
and deploy?

             Sooner or later any JS project
             grows, the amount and
             frequency of commits
             increase, and the
             solution is already out
             dozen JS files that need to be
             collect, and to minimize for
             the load on the server.

                                              38
What is a Gradle?
System assembly
which tries
to combine
all the advantages of Ant,
Maven, Ivy, and
present what
come out with Groovy.


                             39
I have a plan!
      1. Briefly about install Gradle
      2. Creating a build - a script that:
            ● connect the selected files and JS
      minimize them with Closure Compiler;
            ● flood min version of the FTP;
            ● Check the script on the practice;



                                             40
How to install?
1. Downloading a fresh package
                 http://gradle.org/downloads
2. Unpack the disk and add
subdirectory bin in path

3. Check the installation by entering gradle to
the console



                                                  41
JS plug-in for Gradle

There exists an Gradle two plug-in, both based
for GCC, but differ in the rules of the assembly:


https://launchpad.net/gradle-jsli
https://github.com/eriwen/gradle-js-plugin



                                                    42
Writing gradle script
In the root folder, create a new project
file and call it core.gradle

It is assumed that the working directory script
($ {projectDir}) is a subfolder SRP




                                                  43
Check the availability of plug-in set out in
the Maven repository
If there is no
buildscript {
         repositories {
                   mavenCentral()
         }
         dependencies {
         //Install plugin from Maven Repo
         classpath 'com.eriwen:gradle-js-plugin:0.3'
         }
}

 And use it
apply plugin: 'js'
                                                       44
Task plug-in bonding,
inputs and outputs asking
combineJs {
     file1 = fileTree(dir: "${projectDir}/src/Core",
     includes: ['Framework/core.js'])
     file2 = fileTree(dir: "${projectDir}/src/Core",
     includes: ['Framework/strings.js'])
     inputs.files file1 + file2
     outputs.file file("$
     {projectDir}/min/corecombined.js")
}

                                                       45
Plug-in task minification

minifyJs {
  inputs.files fileTree(dir: "${projectDir}/min",
  include: "corecombined.js")
  outputs.file file("${projectDir}/min/core.min.js")
}



                                                 46
Upload to FTP
To use the Ant deploy TASK, which
describe in a separate file - deploycore.xml.

Content you might deploycore.xml
view / copy of the articles
pixelscommander.com

In gradle script call Ant TASK:
ant.importBuild 'deploycore.xml'
                                                47
Finally, call the script gradle
           from the console

gradle -b= core.gradle combineJs minifyJs




                 Questions?
                                        48
Thank you for your attention!


          Presenter:
          Zakharchenko Artem



                                49
Ad

Recommended

Gradle in 45min
Gradle in 45min
Schalk Cronjé
 
Everything as a code
Everything as a code
Aleksandr Tarasov
 
Using the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM Development
Schalk Cronjé
 
Scala, Functional Programming and Team Productivity
Scala, Functional Programming and Team Productivity
7mind
 
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
7mind
 
Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010
Tomek Kaczanowski
 
Hyper-pragmatic Pure FP testing with distage-testkit
Hyper-pragmatic Pure FP testing with distage-testkit
7mind
 
Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)
Joachim Baumann
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection
7mind
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack
7mind
 
Enter the gradle
Enter the gradle
Parameswari Ettiappan
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
All Things Open
 
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Schalk Cronjé
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and Gulp
All Things Open
 
Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012
Anton Arhipov
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writing
Schalk Cronjé
 
Gradle
Gradle
Return on Intelligence
 
Basic Gradle Plugin Writing
Basic Gradle Plugin Writing
Schalk Cronjé
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
Roberto Franchini
 
Better Code: Concurrency
Better Code: Concurrency
Platonov Sergey
 
Automated acceptance test
Automated acceptance test
Bryan Liu
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!
Corneil du Plessis
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017
Andres Almiray
 
Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017
Andres Almiray
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
Andres Almiray
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSF
Jiayun Zhou
 
Gradle,the new build system for android
Gradle,the new build system for android
zhang ghui
 
淺談 Groovy 與 AWS 雲端應用開發整合
淺談 Groovy 與 AWS 雲端應用開發整合
Kyle Lin
 
Dalvik Vm &amp; Jit
Dalvik Vm &amp; Jit
Ankit Somani
 
Веб 2.0 (блоги)
Веб 2.0 (блоги)
Evgeniya Kulyk
 

More Related Content

What's hot (20)

ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection
7mind
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack
7mind
 
Enter the gradle
Enter the gradle
Parameswari Ettiappan
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
All Things Open
 
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Schalk Cronjé
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and Gulp
All Things Open
 
Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012
Anton Arhipov
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writing
Schalk Cronjé
 
Gradle
Gradle
Return on Intelligence
 
Basic Gradle Plugin Writing
Basic Gradle Plugin Writing
Schalk Cronjé
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
Roberto Franchini
 
Better Code: Concurrency
Better Code: Concurrency
Platonov Sergey
 
Automated acceptance test
Automated acceptance test
Bryan Liu
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!
Corneil du Plessis
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017
Andres Almiray
 
Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017
Andres Almiray
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
Andres Almiray
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSF
Jiayun Zhou
 
Gradle,the new build system for android
Gradle,the new build system for android
zhang ghui
 
淺談 Groovy 與 AWS 雲端應用開發整合
淺談 Groovy 與 AWS 雲端應用開發整合
Kyle Lin
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection
7mind
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack
7mind
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
All Things Open
 
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Schalk Cronjé
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and Gulp
All Things Open
 
Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012
Anton Arhipov
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writing
Schalk Cronjé
 
Basic Gradle Plugin Writing
Basic Gradle Plugin Writing
Schalk Cronjé
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
Roberto Franchini
 
Better Code: Concurrency
Better Code: Concurrency
Platonov Sergey
 
Automated acceptance test
Automated acceptance test
Bryan Liu
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!
Corneil du Plessis
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017
Andres Almiray
 
Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017
Andres Almiray
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
Andres Almiray
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSF
Jiayun Zhou
 
Gradle,the new build system for android
Gradle,the new build system for android
zhang ghui
 
淺談 Groovy 與 AWS 雲端應用開發整合
淺談 Groovy 與 AWS 雲端應用開發整合
Kyle Lin
 

Viewers also liked (12)

Dalvik Vm &amp; Jit
Dalvik Vm &amp; Jit
Ankit Somani
 
Веб 2.0 (блоги)
Веб 2.0 (блоги)
Evgeniya Kulyk
 
Js in Automotive - JS.everywhere(2013)
Js in Automotive - JS.everywhere(2013)
Alexandre Morgaut
 
ParisJS meetup 8 - june 2011
ParisJS meetup 8 - june 2011
Alexandre Morgaut
 
Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012
Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012
Alexandre Morgaut
 
Александр Кашеверов — Коротко про WEB: HTML, CSS, JS.
Александр Кашеверов — Коротко про WEB: HTML, CSS, JS.
DataArt
 
Git Version Control System
Git Version Control System
KMS Technology
 
State of the art: Server-side JavaScript - MoscowJS
State of the art: Server-side JavaScript - MoscowJS
Alexandre Morgaut
 
What is version control software and why do you need it?
What is version control software and why do you need it?
Leonid Mamchenkov
 
Develop webservice in PHP
Develop webservice in PHP
Sanil Subhash Chandra Bose
 
Wakanda: a new end-to-end JavaScript platform - JSConf Berlin 2009
Wakanda: a new end-to-end JavaScript platform - JSConf Berlin 2009
Alexandre Morgaut
 
DOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQuery
Remy Sharp
 
Dalvik Vm &amp; Jit
Dalvik Vm &amp; Jit
Ankit Somani
 
Веб 2.0 (блоги)
Веб 2.0 (блоги)
Evgeniya Kulyk
 
Js in Automotive - JS.everywhere(2013)
Js in Automotive - JS.everywhere(2013)
Alexandre Morgaut
 
ParisJS meetup 8 - june 2011
ParisJS meetup 8 - june 2011
Alexandre Morgaut
 
Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012
Wakanda: NoSQL & SSJS for Model-driven Web Applications - SourceDevCon 2012
Alexandre Morgaut
 
Александр Кашеверов — Коротко про WEB: HTML, CSS, JS.
Александр Кашеверов — Коротко про WEB: HTML, CSS, JS.
DataArt
 
Git Version Control System
Git Version Control System
KMS Technology
 
State of the art: Server-side JavaScript - MoscowJS
State of the art: Server-side JavaScript - MoscowJS
Alexandre Morgaut
 
What is version control software and why do you need it?
What is version control software and why do you need it?
Leonid Mamchenkov
 
Wakanda: a new end-to-end JavaScript platform - JSConf Berlin 2009
Wakanda: a new end-to-end JavaScript platform - JSConf Berlin 2009
Alexandre Morgaut
 
DOM Scripting Toolkit - jQuery
DOM Scripting Toolkit - jQuery
Remy Sharp
 
Ad

Similar to Js tacktalk team dev js testing performance (20)

Node.js #digpen presentation
Node.js #digpen presentation
GOSS Interactive
 
Server Side Javascript
Server Side Javascript
rajivmordani
 
Expert JavaScript Programming
Expert JavaScript Programming
Yoshiki Shibukawa
 
Javascript Dependency Management
Javascript Dependency Management
Sean Duncan
 
Using RequireJS for Modular JavaScript Code
Using RequireJS for Modular JavaScript Code
Thomas Lundström
 
Choosing Javascript Libraries to Adopt for Development
Choosing Javascript Libraries to Adopt for Development
Edward Apostol
 
JavaScript Intro
JavaScript Intro
Eric Brown
 
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
GeeksLab Odessa
 
Jslab rssh: JS as language platform
Jslab rssh: JS as language platform
Ruslan Shevchenko
 
State of the art: Server-Side JavaScript - dejeuner fulljs
State of the art: Server-Side JavaScript - dejeuner fulljs
Alexandre Morgaut
 
OGDC2012 Cross-Platform Development On Mobile Devices_Mr.Takaaki Mizuno_DeNA
OGDC2012 Cross-Platform Development On Mobile Devices_Mr.Takaaki Mizuno_DeNA
Buff Nguyen
 
Cross-platform development on mobile devices
Cross-platform development on mobile devices
action.vn
 
A few good JavaScript development tools
A few good JavaScript development tools
Simon Kim
 
Angular Weekend
Angular Weekend
Troy Miles
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScript
Lars Thorup
 
State of the art - server side JavaScript - web-5 2012
State of the art - server side JavaScript - web-5 2012
Alexandre Morgaut
 
AMD - Why, What and How
AMD - Why, What and How
Mike Wilcox
 
Splash
Splash
Brendan Eich
 
Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012
Adam Mokan
 
A New Baseline for Front-End Devs
A New Baseline for Front-End Devs
Rebecca Murphey
 
Node.js #digpen presentation
Node.js #digpen presentation
GOSS Interactive
 
Server Side Javascript
Server Side Javascript
rajivmordani
 
Expert JavaScript Programming
Expert JavaScript Programming
Yoshiki Shibukawa
 
Javascript Dependency Management
Javascript Dependency Management
Sean Duncan
 
Using RequireJS for Modular JavaScript Code
Using RequireJS for Modular JavaScript Code
Thomas Lundström
 
Choosing Javascript Libraries to Adopt for Development
Choosing Javascript Libraries to Adopt for Development
Edward Apostol
 
JavaScript Intro
JavaScript Intro
Eric Brown
 
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
GeeksLab Odessa
 
Jslab rssh: JS as language platform
Jslab rssh: JS as language platform
Ruslan Shevchenko
 
State of the art: Server-Side JavaScript - dejeuner fulljs
State of the art: Server-Side JavaScript - dejeuner fulljs
Alexandre Morgaut
 
OGDC2012 Cross-Platform Development On Mobile Devices_Mr.Takaaki Mizuno_DeNA
OGDC2012 Cross-Platform Development On Mobile Devices_Mr.Takaaki Mizuno_DeNA
Buff Nguyen
 
Cross-platform development on mobile devices
Cross-platform development on mobile devices
action.vn
 
A few good JavaScript development tools
A few good JavaScript development tools
Simon Kim
 
Angular Weekend
Angular Weekend
Troy Miles
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScript
Lars Thorup
 
State of the art - server side JavaScript - web-5 2012
State of the art - server side JavaScript - web-5 2012
Alexandre Morgaut
 
AMD - Why, What and How
AMD - Why, What and How
Mike Wilcox
 
Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012
Adam Mokan
 
A New Baseline for Front-End Devs
A New Baseline for Front-End Devs
Rebecca Murphey
 
Ad

More from Артем Захарченко (8)

Frontend performance metrics
Frontend performance metrics
Артем Захарченко
 
dataflow.pptx
dataflow.pptx
Артем Захарченко
 
Background js
Background js
Артем Захарченко
 
Fullstack javascript. Isomorphic apps
Fullstack javascript. Isomorphic apps
Артем Захарченко
 
Performance optimisation in javascript
Performance optimisation in javascript
Артем Захарченко
 
Build your own multistack JS startup
Build your own multistack JS startup
Артем Захарченко
 
WebRTC in production
WebRTC in production
Артем Захарченко
 
Cloud computing
Cloud computing
Артем Захарченко
 

Js tacktalk team dev js testing performance

  • 1. JavaScript. High Performance Applications 21/03/12 Dev-Pro. net 1
  • 2. Javascript. What is it? • Everything is a object • Class free • Typeless syntax • No compilation • C-like syntax 2
  • 3. Patterns General solution to a commonly occurring problem. Optimal solution to common problem 3
  • 4. Live design patterns demonstration: • Singleton • Module • Prototype • Factory • Decorator 4
  • 6. Local Storage performance <script> localStorage.clear(); for(var i = 0; i < 100; i++) localStorage.setItem(i, 'Value ' + i); </script> 6
  • 11. Regular expressions <div id="foo" class="a foo bar"></div> <script> Benchmark.prototype.setup = function() { var r; var element = document.getElementById('foo'); var reContains = /(?:^| )foo(?: |$)/; function dynamicRegExp(node) { return RegExp('(?:^| )foo(?: |$)').test(node.className); } function inlineRegExp(node) { return /(?:^| )foo(?: |$)/.test(node.className); } function storedRegExp(node) { return reContains.test(node.className); } function stringIndexOf(node) { return (' ' + node.className + ' ').indexOf(' foo ') > -1; } }; </script> 11
  • 13. prototype chain lookup, cached or not <script> if (!Object.create) { Object.create = function(o) { function F() {} F.prototype = o; return new F(); };} var foo = { fun: "weee!" }, bar = Object.create(foo), baz = Object.create(bar), _fun = baz.fun, res; </script> 13
  • 14. prototype chain lookup, cached or not 14
  • 15. Operations which require an implicit primitive-to- object cast/conversion will be slower. 15
  • 16. Operations which require an implicit primitive-to- object cast/conversion will be slower. 16
  • 17. undefined void 0 perf <script> var undefined; </script> <script> Benchmark.prototype.setup = function() { var r; var u; var u2; var useVoid = function(a) { return (a === void 0); }; var useGlobalUndefined = function(a) { return (a === undefined); }; var useLocalUndefined = function(a) { return (a === u2); }; var useTypeOfUndefined = function(a) { return typeof a === 'undefined'; }; }; </script> 17
  • 18. undefined void 0 perf 18
  • 20. JavaScript Unit testing Jasmine is a behavior-driven development framework for testing your JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests. 20
  • 21. Jasmine describe("isLeapYear", function() { it("2004 should be leap year", function() { expect(isLeapYear(2004)).toBeTruthy(); expect(isLeapYear(2004)).toEqual(true); }); 21
  • 27. YUI test framework. Examples 27
  • 28. BUILDING NATIVE APPS WITH Titanium Mobile 28
  • 29. What if you could create apps using JavaScript? 29
  • 31. Titanium Mobile Build Fully Native iPhone Apps 31
  • 32. 32
  • 33. JavaScript on the the sofa 33
  • 34. 34
  • 35. 35
  • 36. 36
  • 37. JS & Gradle assembly, minimizing, deploy 37
  • 38. Why do I need automatic assembly and deploy? Sooner or later any JS project grows, the amount and frequency of commits increase, and the solution is already out dozen JS files that need to be collect, and to minimize for the load on the server. 38
  • 39. What is a Gradle? System assembly which tries to combine all the advantages of Ant, Maven, Ivy, and present what come out with Groovy. 39
  • 40. I have a plan! 1. Briefly about install Gradle 2. Creating a build - a script that: ● connect the selected files and JS minimize them with Closure Compiler; ● flood min version of the FTP; ● Check the script on the practice; 40
  • 41. How to install? 1. Downloading a fresh package http://gradle.org/downloads 2. Unpack the disk and add subdirectory bin in path 3. Check the installation by entering gradle to the console 41
  • 42. JS plug-in for Gradle There exists an Gradle two plug-in, both based for GCC, but differ in the rules of the assembly: https://launchpad.net/gradle-jsli https://github.com/eriwen/gradle-js-plugin 42
  • 43. Writing gradle script In the root folder, create a new project file and call it core.gradle It is assumed that the working directory script ($ {projectDir}) is a subfolder SRP 43
  • 44. Check the availability of plug-in set out in the Maven repository If there is no buildscript { repositories { mavenCentral() } dependencies { //Install plugin from Maven Repo classpath 'com.eriwen:gradle-js-plugin:0.3' } } And use it apply plugin: 'js' 44
  • 45. Task plug-in bonding, inputs and outputs asking combineJs { file1 = fileTree(dir: "${projectDir}/src/Core", includes: ['Framework/core.js']) file2 = fileTree(dir: "${projectDir}/src/Core", includes: ['Framework/strings.js']) inputs.files file1 + file2 outputs.file file("$ {projectDir}/min/corecombined.js") } 45
  • 46. Plug-in task minification minifyJs { inputs.files fileTree(dir: "${projectDir}/min", include: "corecombined.js") outputs.file file("${projectDir}/min/core.min.js") } 46
  • 47. Upload to FTP To use the Ant deploy TASK, which describe in a separate file - deploycore.xml. Content you might deploycore.xml view / copy of the articles pixelscommander.com In gradle script call Ant TASK: ant.importBuild 'deploycore.xml' 47
  • 48. Finally, call the script gradle from the console gradle -b= core.gradle combineJs minifyJs Questions? 48
  • 49. Thank you for your attention! Presenter: Zakharchenko Artem 49