PLOG - Modern Javascripting with Plone
Upcoming SlideShare
Loading in...5

PLOG - Modern Javascripting with Plone






Total Views
Views on SlideShare
Embed Views



3 Embeds 137 111 24 2



Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

PLOG - Modern Javascripting with Plone PLOG - Modern Javascripting with Plone Presentation Transcript

  • "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.
  • ModularJavascript
  • AMD vs CommonJS Scope Remote/Local Asynchrony
  • AMD// define wrapperdefine( // 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 modules code. // the module is exported to the outside world via the // the definition functions returned value. var modC = modA + modB; return modC; }); CommonJS// dependencies specified as neededvar modC = require(modC);// the module is exported by decorating the `exports` free = require(modA) + require(modB);
  • ResuireJS Paths for network/CDN resources. Minimize resources.Optimizing into one lite JavaScript file.
  • Keepingresources 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
  • TestingJavascript
  • Test Frameworks QUnit Jasmine Buster Mocha
  • Test Assertionsexpect.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 choiceChai is a BDD / TDD assertion library for node and the browser. chai.should();; foo.should.equal(bar); foo.should.have.length(3);; var expect = chai.expect; expect(foo); expect(foo).to.equal(bar); expect(foo).to.have.length(3); expect(tea); var assert = chai.assert; assert.typeOf(foo, string); assert.equal(foo, bar); assert.lengthOf(foo, 3), favors); assert.lengthOf(tea.flavors, 3);
  • Test runnersQUnit, Jasmine, Buster, Mocha TESTEM
  • Mockupproject