SlideShare a Scribd company logo
"Modern" Javascript-ing
        Plone
... how to drink less while doing
       Javascript in Plone.
            Rok Garbas / @garbas
Products.ResourcesRegistry
        orders resources,
           minimizes,
          groups them.
Nothing wrong with it,
        right?
              Hard to debug
     Hard to keep resources up to date.
 Nothing / Nada / Niente of our JS is tested.
        Tricky for addons to plugin.
Seriously...

We need to get out shit
      together!
PLOG pledge
                On my honor, I will try,
To serve Plone community and worship **all** Javascript
                         Gods,
 To write Modular, Tested, Documented Javascript code
           And to live by the Girl Scout Law.
Modular
Javascript
AMD vs CommonJS
        Scope
     Remote/Local
      Asynchrony
AMD
// define wrapper
define(
    // dependencies are specified in advance.
    ['modA', 'modB'],
    // the module is declared within a definition function.
    // dependencies are mapped into function parameters.
    function (modA, modB) {
        // inside here is the module's code.
        // the module is exported to the outside world via the
        // the definition function's returned value.
        var modC = modA + modB;
        return modC;
    }
);

                            CommonJS
// dependencies specified as needed
var modC = require('modC');

// the module is exported by decorating the `exports` free variable.
exports.foo = require('modA') + require('modB');
ResuireJS
 Paths for network/CDN resources.
         Minimize resources.
Optimizing into one lite JavaScript file.
Keeping
resources up to
     date
Jam
                      Manage dependencies
                        "npm" for browser
              Really nice integration with RequireJS
$   jam   install backbone
$   jam   upgrade
$   jam   compile compiled.min.js
$   jam   compile --almond compiled-standalone.min.js
Testing
Javascript
Test Frameworks
      QUnit
     Jasmine
      Buster
      Mocha
Test Assertions
expect.js - Minimalistic BDD-style assertions for Node.JS
            and the class="fragment"browser.
       should.js - BDD style assertions for node.js
 better-assert - c-style assert() for nodejs, reporting the
          expression string as the error message
                     Buster, Jasmine -
My assertion library choice
Chai is a BDD / TDD assertion library for node and the
                     browser.
 chai.should();
 foo.should.be.a('string');
 foo.should.equal('bar');
 foo.should.have.length(3);
 tea.should.have.property('flavors').with.length(3);

 var expect = chai.expect;
 expect(foo).to.be.a('string');
 expect(foo).to.equal('bar');
 expect(foo).to.have.length(3);
 expect(tea).to.have.property('flavors').with.length(3);

 var assert = chai.assert;
 assert.typeOf(foo, 'string');
 assert.equal(foo, 'bar');
 assert.lengthOf(foo, 3)
 assert.property(tea, 'favors');
 assert.lengthOf(tea.flavors, 3);
Test runners
QUnit, Jasmine, Buster, Mocha
          TEST'EM
Mockup
project

More Related Content

PDF
The SPDY Protocol
DOC
PDF
Let s Enjoy Node.js
ODP
Presentation of JSConf.eu
PPTX
Introduction to node.js
PDF
Server Side Apocalypse, JS
KEY
Server side scripting smack down - Node.js vs PHP
PDF
Node.js Introduction
The SPDY Protocol
Let s Enjoy Node.js
Presentation of JSConf.eu
Introduction to node.js
Server Side Apocalypse, JS
Server side scripting smack down - Node.js vs PHP
Node.js Introduction

What's hot (20)

PDF
Browserify
PPT
JavaScript Basics with baby steps
PDF
Lightning Talk: Making JS better with Browserify
PDF
LCA 2012: High Availability Sprint
PDF
JUDCon 2010 Boston : TorqueBox
KEY
Node workShop Basic
PPTX
Testing nodejs apps
PDF
Mastering the MongoDB Shell
PPTX
NodeJS
PPTX
Javascript Bundling and modularization
PPT
루비가 얼랭에 빠진 날
PDF
Overview: How to Measure your WebApp
PDF
The Enterprise Strikes Back
PDF
MongoDB + node.js で作るソーシャルゲーム
PDF
JRuby - Enterprise 2.0
ZIP
On Demand Javascript - Scalecamp 2009
PDF
Coffeescript intro
PDF
JUDCon 2010 Boston : BoxGrinder
PDF
When Ruby Meets Java - The Power of Torquebox
PPTX
Ultra fast web development with sinatra
Browserify
JavaScript Basics with baby steps
Lightning Talk: Making JS better with Browserify
LCA 2012: High Availability Sprint
JUDCon 2010 Boston : TorqueBox
Node workShop Basic
Testing nodejs apps
Mastering the MongoDB Shell
NodeJS
Javascript Bundling and modularization
루비가 얼랭에 빠진 날
Overview: How to Measure your WebApp
The Enterprise Strikes Back
MongoDB + node.js で作るソーシャルゲーム
JRuby - Enterprise 2.0
On Demand Javascript - Scalecamp 2009
Coffeescript intro
JUDCon 2010 Boston : BoxGrinder
When Ruby Meets Java - The Power of Torquebox
Ultra fast web development with sinatra
Ad

Viewers also liked (9)

PDF
Guillaume St Etienne : Services et Contrats Agiles
ODP
Theming Plone with Deliverance
ODP
Migrations With Transmogrifier
ODP
Transmogrifier: content migration and time traveling
ODP
Ubuntuday 2014
ODP
Journeys with Transmogrifier and friends or How not to get stuck in the Plone...
PPTX
Aspek hukum dalam ekonomi 'monopoli dan persaingan usaha tidak sehat'
PDF
The Near Future of CSS
PDF
Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...
Guillaume St Etienne : Services et Contrats Agiles
Theming Plone with Deliverance
Migrations With Transmogrifier
Transmogrifier: content migration and time traveling
Ubuntuday 2014
Journeys with Transmogrifier and friends or How not to get stuck in the Plone...
Aspek hukum dalam ekonomi 'monopoli dan persaingan usaha tidak sehat'
The Near Future of CSS
Stay Up To Date on the Latest Happenings in the Boardroom: Recommended Summer...
Ad

Similar to PLOG - Modern Javascripting with Plone (20)

PDF
Module, AMD, RequireJS
PDF
Using RequireJS for Modular JavaScript Code
PDF
Asynchronous Module Definition (AMD)
PDF
DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
ODP
Javascript Update May 2013
PDF
DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
PPTX
A few good JavaScript development tools
PDF
Require js training
PDF
IOC + Javascript
PDF
JavaScript Dependencies, Modules & Browserify
PPT
JavaScript Modules in Practice
PPT
Node js
PDF
Dependency Management with RequireJS
PDF
Frontrow conf
PPTX
Js tacktalk team dev js testing performance
PPTX
How to build a JavaScript toolkit
PPTX
Javascript first-class citizenery
PDF
Seven Versions of One Web Application
PDF
JavaScript Modules Done Right
KEY
Introducing the Seneca MVP framework for Node.js
Module, AMD, RequireJS
Using RequireJS for Modular JavaScript Code
Asynchronous Module Definition (AMD)
DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
Javascript Update May 2013
DownTheRabbitHole.js – How to Stay Sane in an Insane Ecosystem
A few good JavaScript development tools
Require js training
IOC + Javascript
JavaScript Dependencies, Modules & Browserify
JavaScript Modules in Practice
Node js
Dependency Management with RequireJS
Frontrow conf
Js tacktalk team dev js testing performance
How to build a JavaScript toolkit
Javascript first-class citizenery
Seven Versions of One Web Application
JavaScript Modules Done Right
Introducing the Seneca MVP framework for Node.js

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Spectroscopy.pptx food analysis technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
sap open course for s4hana steps from ECC to s4
Teaching material agriculture food technology
Advanced methodologies resolving dimensionality complications for autism neur...
Network Security Unit 5.pdf for BCA BBA.
Spectroscopy.pptx food analysis technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Spectral efficient network and resource selection model in 5G networks
Dropbox Q2 2025 Financial Results & Investor Presentation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Building Integrated photovoltaic BIPV_UPV.pdf
Electronic commerce courselecture one. Pdf
Review of recent advances in non-invasive hemoglobin estimation
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Understanding_Digital_Forensics_Presentation.pptx
MYSQL Presentation for SQL database connectivity
Mobile App Security Testing_ A Comprehensive Guide.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
sap open course for s4hana steps from ECC to s4

PLOG - Modern Javascripting with Plone

  • 1. "Modern" Javascript-ing Plone ... how to drink less while doing Javascript in Plone. Rok Garbas / @garbas
  • 2. Products.ResourcesRegistry orders resources, minimizes, groups them.
  • 3. Nothing wrong with it, right? Hard to debug Hard to keep resources up to date. Nothing / Nada / Niente of our JS is tested. Tricky for addons to plugin.
  • 4. Seriously... We need to get out shit together!
  • 5. PLOG pledge On my honor, I will try, To serve Plone community and worship **all** Javascript Gods, To write Modular, Tested, Documented Javascript code And to live by the Girl Scout Law.
  • 7. AMD vs CommonJS Scope Remote/Local Asynchrony
  • 8. AMD // define wrapper define( // dependencies are specified in advance. ['modA', 'modB'], // the module is declared within a definition function. // dependencies are mapped into function parameters. function (modA, modB) { // inside here is the module's code. // the module is exported to the outside world via the // the definition function's returned value. var modC = modA + modB; return modC; } ); CommonJS // dependencies specified as needed var modC = require('modC'); // the module is exported by decorating the `exports` free variable. exports.foo = require('modA') + require('modB');
  • 9. ResuireJS Paths for network/CDN resources. Minimize resources. Optimizing into one lite JavaScript file.
  • 11. Jam Manage dependencies "npm" for browser Really nice integration with RequireJS $ jam install backbone $ jam upgrade $ jam compile compiled.min.js $ jam compile --almond compiled-standalone.min.js
  • 13. Test Frameworks QUnit Jasmine Buster Mocha
  • 14. Test Assertions expect.js - Minimalistic BDD-style assertions for Node.JS and the class="fragment"browser. should.js - BDD style assertions for node.js better-assert - c-style assert() for nodejs, reporting the expression string as the error message Buster, Jasmine -
  • 15. My assertion library choice Chai is a BDD / TDD assertion library for node and the browser. chai.should(); foo.should.be.a('string'); foo.should.equal('bar'); foo.should.have.length(3); tea.should.have.property('flavors').with.length(3); var expect = chai.expect; expect(foo).to.be.a('string'); expect(foo).to.equal('bar'); expect(foo).to.have.length(3); expect(tea).to.have.property('flavors').with.length(3); var assert = chai.assert; assert.typeOf(foo, 'string'); assert.equal(foo, 'bar'); assert.lengthOf(foo, 3) assert.property(tea, 'favors'); assert.lengthOf(tea.flavors, 3);
  • 16. Test runners QUnit, Jasmine, Buster, Mocha TEST'EM