Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Modular JavaScript: FEL, Feb 2013

Modular JavaScript: FEL, Feb 2013

Jack Franklin

February 28, 2013
Tweet

More Decks by Jack Franklin

Other Decks in Technology

Transcript

  1. Who is this guy? Author of "Beginning jQuery" Blogger at

    javascriptplayground.com Developer for Kainos (JS & Ruby) Comp-Sci student at University of Bath
  2. Book Giveaway! Tweet your most cringe-worthy, clean joke with the

    hashtag #feljoke I'll pick two winners once I'm done talking.
  3. modules don't know about each other modules are independent modules

    don't talk to each other directly so they need some way of communicating
  4. Modules have no knowledge of each other Modules publish events

    Modules subscribe to events Loosely coupled, more maintainable modules don't publish events to specific other modules, but just do it generally
  5. The Module Pattern var APP = (function() { var _count

    = 0; var incrementCount = function() { _count++; } var getCount = function() { return _count; } return { incrementCount: incrementCount, getCount: getCount }; })(); _count is kept private can only be manipulated through incrementCount
  6. RequireJS Implements the AMD Spec define() modules require() them No

    more <script> tag rubbish Dynamic module loading Build tool
  7. GruntJS Run tasks on your JS, including plugins for: -

    Concatenating - Minifying - RequireJS Build Tool - Sass / LESS - CoffeeScript - Handlebars / Jade / templating - QUnit / Jasmine / Mocha / testing
  8. - one step at a time - split your JS

    up (in development) - use a tool (Grunt) for production JS - jQuery does Pub/Sub - initial hurdles outweighed by long-term gains