SlideShare uma empresa Scribd logo
1 de 38
Baixar para ler offline
Fabian Jakobs | 1&1


JavaScript Tooling
     Minimize, Lint & Co
About me

• Fabian Jakobs
  <fabian.jakobs@1und1.de>
• JavaScript Framework developer
  at 1&1
     – Framework architect of the
       Javascript GUI Framework
       qooxdoo




Fabian Jakobs | 1&1
Overview

• Professional tooling for JavaScript
• Focus on larger JavaScript based applications
• Will demonstrate the presented techniques on
  a simple example application




Fabian Jakobs | 1&1
Example Program

• Performs „Filter-as-you-
  type“
• Separation of
     – Content (HTML)
     – Style (CSS)
     – Behavior (JavaScript)
• Uses qooxdoo DOM API
• No qooxdoo GUI
  application                  Demo



Fabian Jakobs | 1&1
Demo – Content




Fabian Jakobs | 1&1
Demo – Style
body {                                      h1 {
  background-color: #1D1D20;                  color: #FFFFFF
  padding: 40px 20px;                       }
  color: #BBBBBB;
  font: 11px quot;Lucida Grandequot;, quot;sans-serifquot;; #result {
  text-align: center;                         margin: 20px;
}                                             background-color: #1D1D20;
                                              padding: 20px;
#searchContainer {                            color: #BBBBBB;
  position: absolute;                         -moz-border-radius: 8px;
  background-color: #7389AE;                  -webkit-border-radius: 8px;
  width: 500px;                             }
  margin: 20px 0px 0px -265px;
  padding: 15px;                            .match {
  left: 50%;                                  font-weight: bold;
  color: white;                               color: #FACE8F;
  -moz-border-radius: 7px;                  }
  -webkit-border-radius: 7px;
}



Fabian Jakobs | 1&1
Demo – Behavior




Fabian Jakobs | 1&1
Overview - Tools

•   Linker
•   API documentation
•   Lint
•   Optimizer/Packer




Fabian Jakobs | 1&1
What is under the hood?
             ShrinkSafe                              JSLint
                              qooxdoo tools
           YUI Compressor                         (JavaScript
                            (Python JS parser)
               (Rhino)                             JS parser)

                               Syntax Tree

                                                 JSMin
                                 Parser
                                                 JSDoc

                                 Tokens

                                 Scanner
                                (RegExp)



                               JavaScript

Fabian Jakobs | 1&1
Linker

• Detect dependencies between JavaScript fles
• Sorted list of fles to include
• Generate an optimized version of the
  application




Fabian Jakobs | 1&1
Linker – Motivation

• The dependency Graph of the demo




Fabian Jakobs | 1&1
Linker – Motivation

• Been there – done that




Fabian Jakobs | 1&1
Linker – Common Scenario
• Scenario
     – Use of a pre build version of the framework used
     – Manage include list of own JavaScript fles manually
• Problems
     – You always include the full framework even if only parts of it
       are used
     – managing dependencies manually doesn't scale
     – Needs separate solution for deployment (combination of
       fles)



Fabian Jakobs | 1&1
Linker - Solution

• Solution
     – (semi-) automatic detection of dependencies
           • needs knowledge about the Framework
     – Generation of loader scripts
     – Generation of „compiled“ application fles
• Implementations
     – dojo build system
           • evaluates „dojo.require()“
     – qooxdoo
           • „knows“ qooxdoo class defnitions
Fabian Jakobs | 1&1
Linker – Demo




Fabian Jakobs | 1&1
Lint

• Static code analysis
     – fnd common coding mistakes
     – enforce coding guidelines
• Especially useful in dynamic languages, where
  errors
     – often occur only at runtime
     – only under certain conditions
     – have strange side effects and are hard to fnd


Fabian Jakobs | 1&1
Lint – Can you fnd all errors?
• This code is full of
     – errors
     – bad JavaScript style
• Demonstrate two lint tools
     – JSLint by Douglas Crockford
     – ecmalint (part of qooxdoo)
• Other tools
     – JavaScript Lint
     – YUI packer (-v parameter)


Fabian Jakobs | 1&1
Lint – Ecmalint
• Finds
     – errors related to variable scope
         • undefned variables
         • unused variables
     – redefnition of map keys
     – deprecated methods (eval,
       alert, ...)
• Part of qooxdoo
• Works with any JavaScript


Fabian Jakobs | 1&1
Lint – Ecmalint

    Use of undefined or global identifier 'xO'



                Unused identifier 'j'


     Use of undefined or global identifier 'i'


             Map key 'add' redefined


    Use of deprecated global identifier 'alert'



Fabian Jakobs | 1&1
Lint – JSLint

• Checks for bad coding style
• by Douglas Crockford
     – “Will hurt your feelings”
• Reports
     – Missing semicolons
     – Unreachable code
     – Missing blocks
     – Many more

Fabian Jakobs | 1&1
Lint – JSLint
                Missing semicolon.



       Expected '{' and instead saw 'sum'.


          Use '===' to compare with '0'.


      Expected '{' and instead saw 'throw'.


                Missing semicolon.


        Unreachable 'return' after 'return'.

Fabian Jakobs | 1&1
Lint – Summary

• Lint tools can help fnding bugs early
• Should be run regularly
• Should be integrated into the build system


                 BUT: Cannot replace testing!



Fabian Jakobs | 1&1
API Documentation




Fabian Jakobs | 1&1
API Documentation

• Generate API documentation
• Most JavaScript Frameworks have API
  documentation for their classes
• Must understand the framework




Fabian Jakobs | 1&1
API Documentation – JSDoc

•   Non framework tool
•   Uses JavaDoc like documentation comments
•   Only basic JavaScript OO features
•   Does not understand
     – OO notation of most frameworks
     – OO notation of qooxdoo
• Generates boring static HTML :-)


Fabian Jakobs | 1&1
API Documentation – Demo




Fabian Jakobs | 1&1
Deploy

• Optimize application for deployment
     – Compress fles
           • Gzip
           • JavaScript compression
     – Combine fles
           • Improves startup time
           • JavaScript, CSS, images
     – Optimize/Obfuscate JavaScript


Fabian Jakobs | 1&1
Deploy – JavaScript Packer
                Remove     Remove      Rename      safe   Client
                comments   white space local              performance
                                       variables          impact
Dean            yes        yes         yes         yes    negative
Edward's                                                  (uses eval)
Packer

YUI             yes        yes         yes         yes    neutral
Compressor

Dojo            yes        yes         yes         yes    neutral
ShrinkSafe
Doulas          yes        yes         no          no     neutral
Crockford's
JSMin
qooxdoo         yes        yes         yes         yes    positive
generator.py                                              (string
                                                          optimizer)


Fabian Jakobs | 1&1
Deploy – JavaScript Packer




Fabian Jakobs | 1&1
Deploy – JavaScript Packer
• Remove local variables




Fabian Jakobs | 1&1
Deploy – JavaScript Packer
• Optimize strings




Fabian Jakobs | 1&1
Deploy – JavaScript Packer
• Remove white space




Fabian Jakobs | 1&1
Packer – Demo




Fabian Jakobs | 1&1
Deploy - Further optimizations

• Rename private members
     – Needs framework knowledge
• Remove debugging code
• Generate browser specifc builds
• Inline HTML Templates
     – Dojo inlines dijit template
• Combine images and CSS



Fabian Jakobs | 1&1
Questions?




Fabian Jakobs | 1&1
Links – Linker, integrated build systems

• dojo build system
    http://dojotoolkit.org/book/dojo-book-0-9/part-4-meta-dojo/package-system-and-custom-builds

• qooxdoo generator2
    http://qooxdoo.org/documentation/general/generator2




Fabian Jakobs | 1&1
Links

• API Documentation
   – JSDoc http://jsdoc.sourceforge.net/
   – dojo API viewer http://api.dojotoolkit.org/
   – ExtJS API viewer http://extjs.com/deploy/dev/docs/
   – qooxdoo API viewer http://api.qooxdoo.org/
• Lint
   – JSLint http://www.jslint.com/
   – JavaScript Lint http://www.javascriptlint.com/


Fabian Jakobs | 1&1
Links - Packer

• Dean Edward's Packer
  http://dean.edwards.name/packer/
• YUI Compressor
  http://developer.yahoo.com/yui/compressor/
• dojo ShrinkSafe http://dojotoolkit.org/docs/shrinksafe
• JSMin http://www.crockford.com/javascript/jsmin.html




Fabian Jakobs | 1&1

Mais conteĂşdo relacionado

Mais procurados

Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraLunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and Capybara
Marc Seeger
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
Lucas Jellema
 

Mais procurados (13)

Developing web applications in 2010
Developing web applications in 2010Developing web applications in 2010
Developing web applications in 2010
 
キレイ会議 on Laravel
キレイ会議 on Laravelキレイ会議 on Laravel
キレイ会議 on Laravel
 
Introduction To Grails
Introduction To GrailsIntroduction To Grails
Introduction To Grails
 
GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraLunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and Capybara
 
Groovy & Grails
Groovy & GrailsGroovy & Grails
Groovy & Grails
 
Webpack & EcmaScript 6 (Webelement #32)
Webpack & EcmaScript 6 (Webelement #32)Webpack & EcmaScript 6 (Webelement #32)
Webpack & EcmaScript 6 (Webelement #32)
 
Launchpad: Lessons Learnt
Launchpad: Lessons LearntLaunchpad: Lessons Learnt
Launchpad: Lessons Learnt
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
 
Myphp-busters: symfony framework
Myphp-busters: symfony frameworkMyphp-busters: symfony framework
Myphp-busters: symfony framework
 
Myphp-busters: symfony framework (PHPCon.it)
Myphp-busters: symfony framework (PHPCon.it)Myphp-busters: symfony framework (PHPCon.it)
Myphp-busters: symfony framework (PHPCon.it)
 

Destaque (7)

Barberis - Protocube
Barberis - ProtocubeBarberis - Protocube
Barberis - Protocube
 
Beampoint Purchase Pricing Partners 12030
Beampoint Purchase Pricing Partners 12030Beampoint Purchase Pricing Partners 12030
Beampoint Purchase Pricing Partners 12030
 
Matsuo Katsu
Matsuo KatsuMatsuo Katsu
Matsuo Katsu
 
Uudrt 01 1954
Uudrt 01 1954Uudrt 01 1954
Uudrt 01 1954
 
Uu 16 1951
Uu 16 1951Uu 16 1951
Uu 16 1951
 
Uu 01 1950
Uu 01 1950Uu 01 1950
Uu 01 1950
 
Uudrt 07 1958
Uudrt 07 1958Uudrt 07 1958
Uudrt 07 1958
 

Semelhante a DLW Europe - JavaScript Tooling

Kann JavaScript elegant sein?
Kann JavaScript elegant sein?Kann JavaScript elegant sein?
Kann JavaScript elegant sein?
jbandi
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The Jvm
QConLondon2008
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
Amit Solanki
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008
rajivmordani
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
PerconaPerformance
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
Fabien Potencier
 
Javascript Framework Roundup FYB
Javascript Framework Roundup FYBJavascript Framework Roundup FYB
Javascript Framework Roundup FYB
nukeevry1
 

Semelhante a DLW Europe - JavaScript Tooling (20)

Why Architecture in Web Development matters
Why Architecture in Web Development mattersWhy Architecture in Web Development matters
Why Architecture in Web Development matters
 
Kann JavaScript elegant sein?
Kann JavaScript elegant sein?Kann JavaScript elegant sein?
Kann JavaScript elegant sein?
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The Jvm
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008
 
Practical Groovy DSL
Practical Groovy DSLPractical Groovy DSL
Practical Groovy DSL
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overview
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
 
Building a JavaScript Library
Building a JavaScript LibraryBuilding a JavaScript Library
Building a JavaScript Library
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
 
How to make Ajax Libraries work for you
How to make Ajax Libraries work for youHow to make Ajax Libraries work for you
How to make Ajax Libraries work for you
 
JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)
 
Lecture 8 - Qooxdoo - Rap Course At The University Of Szeged
Lecture 8 - Qooxdoo - Rap Course At The University Of SzegedLecture 8 - Qooxdoo - Rap Course At The University Of Szeged
Lecture 8 - Qooxdoo - Rap Course At The University Of Szeged
 
JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
Plugins 2.0: The Overview
Plugins 2.0: The OverviewPlugins 2.0: The Overview
Plugins 2.0: The Overview
 
Javascript Dependency Management
Javascript Dependency ManagementJavascript Dependency Management
Javascript Dependency Management
 
Javascript Framework Roundup FYB
Javascript Framework Roundup FYBJavascript Framework Roundup FYB
Javascript Framework Roundup FYB
 

Mais de Fabian Jakobs

Amsterdam.js talk: node webkit
Amsterdam.js talk: node webkitAmsterdam.js talk: node webkit
Amsterdam.js talk: node webkit
Fabian Jakobs
 

Mais de Fabian Jakobs (11)

Amsterdam.js talk: node webkit
Amsterdam.js talk: node webkitAmsterdam.js talk: node webkit
Amsterdam.js talk: node webkit
 
Bespin, Skywriter, Ace The Past, Present and Future of online Code Editing
Bespin, Skywriter, Ace The Past, Present and Future of online Code EditingBespin, Skywriter, Ace The Past, Present and Future of online Code Editing
Bespin, Skywriter, Ace The Past, Present and Future of online Code Editing
 
Kick ass code editing and end to end JavaScript debugging
Kick ass code editing and end to end JavaScript debuggingKick ass code editing and end to end JavaScript debugging
Kick ass code editing and end to end JavaScript debugging
 
Autopsy Of A Widget
Autopsy Of A WidgetAutopsy Of A Widget
Autopsy Of A Widget
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script Applications
 
Tdd For GuIs
Tdd For GuIsTdd For GuIs
Tdd For GuIs
 
Und es geht doch - TDD fĂźr GUIs
Und es geht doch - TDD fĂźr GUIsUnd es geht doch - TDD fĂźr GUIs
Und es geht doch - TDD fĂźr GUIs
 
Going Virtual
Going VirtualGoing Virtual
Going Virtual
 
Going Virtual
Going VirtualGoing Virtual
Going Virtual
 
Qooxdoo 0.8 - Das Neue Gui Toolkit
Qooxdoo 0.8 - Das Neue Gui ToolkitQooxdoo 0.8 - Das Neue Gui Toolkit
Qooxdoo 0.8 - Das Neue Gui Toolkit
 
Ajax In Action 2008 - Gui Development With qooxdoo
Ajax In Action 2008 - Gui Development With qooxdooAjax In Action 2008 - Gui Development With qooxdoo
Ajax In Action 2008 - Gui Development With qooxdoo
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

DLW Europe - JavaScript Tooling

  • 1. Fabian Jakobs | 1&1 JavaScript Tooling Minimize, Lint & Co
  • 2. About me • Fabian Jakobs <fabian.jakobs@1und1.de> • JavaScript Framework developer at 1&1 – Framework architect of the Javascript GUI Framework qooxdoo Fabian Jakobs | 1&1
  • 3. Overview • Professional tooling for JavaScript • Focus on larger JavaScript based applications • Will demonstrate the presented techniques on a simple example application Fabian Jakobs | 1&1
  • 4. Example Program • Performs „Filter-as-you- type“ • Separation of – Content (HTML) – Style (CSS) – Behavior (JavaScript) • Uses qooxdoo DOM API • No qooxdoo GUI application Demo Fabian Jakobs | 1&1
  • 6. Demo – Style body { h1 { background-color: #1D1D20; color: #FFFFFF padding: 40px 20px; } color: #BBBBBB; font: 11px quot;Lucida Grandequot;, quot;sans-serifquot;; #result { text-align: center; margin: 20px; } background-color: #1D1D20; padding: 20px; #searchContainer { color: #BBBBBB; position: absolute; -moz-border-radius: 8px; background-color: #7389AE; -webkit-border-radius: 8px; width: 500px; } margin: 20px 0px 0px -265px; padding: 15px; .match { left: 50%; font-weight: bold; color: white; color: #FACE8F; -moz-border-radius: 7px; } -webkit-border-radius: 7px; } Fabian Jakobs | 1&1
  • 8. Overview - Tools • Linker • API documentation • Lint • Optimizer/Packer Fabian Jakobs | 1&1
  • 9. What is under the hood? ShrinkSafe JSLint qooxdoo tools YUI Compressor (JavaScript (Python JS parser) (Rhino) JS parser) Syntax Tree JSMin Parser JSDoc Tokens Scanner (RegExp) JavaScript Fabian Jakobs | 1&1
  • 10. Linker • Detect dependencies between JavaScript fles • Sorted list of fles to include • Generate an optimized version of the application Fabian Jakobs | 1&1
  • 11. Linker – Motivation • The dependency Graph of the demo Fabian Jakobs | 1&1
  • 12. Linker – Motivation • Been there – done that Fabian Jakobs | 1&1
  • 13. Linker – Common Scenario • Scenario – Use of a pre build version of the framework used – Manage include list of own JavaScript fles manually • Problems – You always include the full framework even if only parts of it are used – managing dependencies manually doesn't scale – Needs separate solution for deployment (combination of fles) Fabian Jakobs | 1&1
  • 14. Linker - Solution • Solution – (semi-) automatic detection of dependencies • needs knowledge about the Framework – Generation of loader scripts – Generation of „compiled“ application fles • Implementations – dojo build system • evaluates „dojo.require()“ – qooxdoo • „knows“ qooxdoo class defnitions Fabian Jakobs | 1&1
  • 16. Lint • Static code analysis – fnd common coding mistakes – enforce coding guidelines • Especially useful in dynamic languages, where errors – often occur only at runtime – only under certain conditions – have strange side effects and are hard to fnd Fabian Jakobs | 1&1
  • 17. Lint – Can you fnd all errors? • This code is full of – errors – bad JavaScript style • Demonstrate two lint tools – JSLint by Douglas Crockford – ecmalint (part of qooxdoo) • Other tools – JavaScript Lint – YUI packer (-v parameter) Fabian Jakobs | 1&1
  • 18. Lint – Ecmalint • Finds – errors related to variable scope • undefned variables • unused variables – redefnition of map keys – deprecated methods (eval, alert, ...) • Part of qooxdoo • Works with any JavaScript Fabian Jakobs | 1&1
  • 19. Lint – Ecmalint Use of undefined or global identifier 'xO' Unused identifier 'j' Use of undefined or global identifier 'i' Map key 'add' redefined Use of deprecated global identifier 'alert' Fabian Jakobs | 1&1
  • 20. Lint – JSLint • Checks for bad coding style • by Douglas Crockford – “Will hurt your feelings” • Reports – Missing semicolons – Unreachable code – Missing blocks – Many more Fabian Jakobs | 1&1
  • 21. Lint – JSLint Missing semicolon. Expected '{' and instead saw 'sum'. Use '===' to compare with '0'. Expected '{' and instead saw 'throw'. Missing semicolon. Unreachable 'return' after 'return'. Fabian Jakobs | 1&1
  • 22. Lint – Summary • Lint tools can help fnding bugs early • Should be run regularly • Should be integrated into the build system BUT: Cannot replace testing! Fabian Jakobs | 1&1
  • 24. API Documentation • Generate API documentation • Most JavaScript Frameworks have API documentation for their classes • Must understand the framework Fabian Jakobs | 1&1
  • 25. API Documentation – JSDoc • Non framework tool • Uses JavaDoc like documentation comments • Only basic JavaScript OO features • Does not understand – OO notation of most frameworks – OO notation of qooxdoo • Generates boring static HTML :-) Fabian Jakobs | 1&1
  • 26. API Documentation – Demo Fabian Jakobs | 1&1
  • 27. Deploy • Optimize application for deployment – Compress fles • Gzip • JavaScript compression – Combine fles • Improves startup time • JavaScript, CSS, images – Optimize/Obfuscate JavaScript Fabian Jakobs | 1&1
  • 28. Deploy – JavaScript Packer Remove Remove Rename safe Client comments white space local performance variables impact Dean yes yes yes yes negative Edward's (uses eval) Packer YUI yes yes yes yes neutral Compressor Dojo yes yes yes yes neutral ShrinkSafe Doulas yes yes no no neutral Crockford's JSMin qooxdoo yes yes yes yes positive generator.py (string optimizer) Fabian Jakobs | 1&1
  • 29. Deploy – JavaScript Packer Fabian Jakobs | 1&1
  • 30. Deploy – JavaScript Packer • Remove local variables Fabian Jakobs | 1&1
  • 31. Deploy – JavaScript Packer • Optimize strings Fabian Jakobs | 1&1
  • 32. Deploy – JavaScript Packer • Remove white space Fabian Jakobs | 1&1
  • 34. Deploy - Further optimizations • Rename private members – Needs framework knowledge • Remove debugging code • Generate browser specifc builds • Inline HTML Templates – Dojo inlines dijit template • Combine images and CSS Fabian Jakobs | 1&1
  • 36. Links – Linker, integrated build systems • dojo build system http://dojotoolkit.org/book/dojo-book-0-9/part-4-meta-dojo/package-system-and-custom-builds • qooxdoo generator2 http://qooxdoo.org/documentation/general/generator2 Fabian Jakobs | 1&1
  • 37. Links • API Documentation – JSDoc http://jsdoc.sourceforge.net/ – dojo API viewer http://api.dojotoolkit.org/ – ExtJS API viewer http://extjs.com/deploy/dev/docs/ – qooxdoo API viewer http://api.qooxdoo.org/ • Lint – JSLint http://www.jslint.com/ – JavaScript Lint http://www.javascriptlint.com/ Fabian Jakobs | 1&1
  • 38. Links - Packer • Dean Edward's Packer http://dean.edwards.name/packer/ • YUI Compressor http://developer.yahoo.com/yui/compressor/ • dojo ShrinkSafe http://dojotoolkit.org/docs/shrinksafe • JSMin http://www.crockford.com/javascript/jsmin.html Fabian Jakobs | 1&1