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

Modern Frontend Development

Modern Frontend Development

Thorsten Rinne

February 13, 2014
Tweet

More Decks by Thorsten Rinne

Other Decks in Programming

Transcript

  1. THORSTEN RINNE ‣ studied CS ‣ Team Lead Engineering ‣

    Yatego GmbH ‣ phpMyFAQ ! ‣ @ThorstenRinne
  2. Today’s agenda Editor / IDE Browser Browser Dev Tools $

    The command line Development Tools Demo
  3. Which Versions? Chrome latest (currently version 32) Chromium latest (currently

    version 34) Firefox latest (currently version 27) Firefox Nightly latest (currently version 30) Safari latest (currently version 6.1 / 7) Forget Opera, as it’s just a Chrome
  4. Which IE versions? Internet Explorer 7 (?) Internet Explorer 8

    Internet Explorer 9 Internet Explorer 10 Internet Explorer 11
  5. Performance measuring Overview of memory usage Helps searching for performance

    problems Layout or scripts Our goal should be 60 frames per second :-)
  6. Memory and DOM Leaks JavaScript CPU Profiling Heap Snapshot for

    JavaScript objects DOM nodes Search for potential memory and/or DOM leaks
  7. Mobile Testing User Agent Different devices Android iOS Windows Phone

    Simulation of touch events Changing geolocation and accelerometers
  8. Socket.IO: cross browser sockets Express: like Sinatra or Silex Grunt:

    a JavaScript task runner Bower: a package manager for the web Yeoman: CLI interface for scaffolding JSHint / JSLint
  9. The JavaScript Task Runner task based CLI tool like make

    / rake / ant / phing Configuration in JavaScript Huge community hundreds of plugins Linting, Concat, Watcher, Testing out of the box
  10. { "name": "yatego.com", "version": "2.0.0", "dependencies": {}, "devDependencies": { "grunt":

    "~0.4.1", "grunt-contrib-jshint": "~0.4.1", "grunt-contrib-uglify": "~0.2.2" }, "engines": { "node": ">=0.10.0" }, "author": "Yatego GmbH", } package.json
  11. module.exports = function(grunt) { ! grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), uglify: {

    options: { banner: '/*! <%= grunt.template.today("yyyy-mm-dd") %> */\n' }, build: { src: 'src/<%= pkg.name %>.js', dest: 'build/<%= pkg.name %>.min.js' } } }); ! grunt.loadNpmTasks('grunt-contrib-uglify'); ! grunt.registerTask('default', ['uglify']); ! }; Gruntfile.js
  12. // Run Jasmine and DalekJS tests grunt.registerTask(
 'testrun',
 ['jshint', 'jasmine',

    'dalek'] ); ! // Build production grunt.registerTask(
 'production', ['copy', 'less', 'cssmin', 'jshint', 'uglify'] ); Grunt Tasks
  13. LiveReload Plugins for Chrome Firefox Safari Triggers page reload via

    grunt watch Browser extensions on http://livereload.com/
  14. Package Manager for the web Install and remove packages No

    external dependencies No sudo permissions Blazing fast installation:
 
 $ npm install bower -g
  15. How to install packages ! ! ! $ bower install

    $ bower install <package> $ bower install <package>#<version> $ bower install <name>=<package>#<version>
  16. Package resources Registered Bower packages like jQuery Git repositories Local

    folders URLs with .zip/.tar.gz files Will be installed to bower_components by default
  17. Configuration bower.json {
 "name": "yatego.com",
 "version": "2.0.0",
 "dependencies": {
 "jquery":

    "1.10.2",
 "bootstrap": "3.0.0",
 "modernizr": "2.6.2"
 },
 "devDependencies": {
 "jasmine": "~1.3.1", },
 "resolutions": {
 "jquery": "1.10.2"
 }
 }
  18. Testing Unittests with Jasmine PhantomJS Chrome Firefox Chrome Canary Firefox

    Nightly
 UI Testing with DalekJS PhantomJS Chrome Firefox Internet Explorer!
  19. Jasmine describe("Cart", function() { ! beforeEach(function() { $.yategoCart().removeAll(); }); !

    it("Checks if add item works", function() { $.yategoCart().addItem("test-pos-1", "test-offer-1", 3); expect($.yategoCart().hasItem("test-offer-1")).toEqual(true); }); ! it("Checks if change quantity works", function() { $.yategoCart().addItem("test-pos-2", "test-offer-2", 3); $.yategoCart().addItemQty("test-offer-2", 2); expect($.yategoCart().getItemQty("test-offer-2")).toEqual(5); }); });
  20. Jasmine via PhantomJS $ grunt jasmine Running "jasmine:pivotal" (jasmine) task

    Testing jasmine specs via phantom ............................ 28 specs in 0.229s. >> 0 failures ! Done, without errors.
  21. Testing with DalekJS New UI Testing Framework Early stage, currently

    version 0.0.8 Faster than Selenium Tests written in JavaScript Supports all browsers and PhantomJS
  22. Testing with DalekJS module.exports = { 'Page title is correct':

    function (test) { test.open('http://www.yatego.dev') .assert.title().is('Yatego Shopping', 'It has title') .done(); }, 'Search page is correct': function (test) { test.open('http://www.yatego.dev/search?q=Test') .assert.title().is('Test - yatego.com', 'It has title') .done(); } };
  23. Yeoman Scaffolding of new apps Writes Grunt configuration Yeoman =

    Grunt + Bower + Awesomeness Blazing fast installation
 
 $ npm install -g yo

  24. Yeoman $ npm install -g generator-webapp
 
 $ cd /path/to/webroot


    
 $ mkdir nfqApp
 
 $ cd nfqApp
 
 $ yo nfqApp

  25. Generator WebApp Watcher for HTML, CSS and JS with LiveReload

    Builtin Webserver at Port 9000 JSHint Mocha tests Bootstrap 3
  26. Frontend vs. Backend Frontend 3 Developer Bootstrap 3 based Testen

    via Jasmine Grunt / LiveReload Deployment Assetserver
 Backend 6 Developer Symfony 2.3 Testen via PHPUnit app/console + ant Deployment
 Capifony
  27. Advantages everyone could use his own workflow Test-Driven-Development for frontend

    and backend LiveReload saves hitting the F5 key all the time Many JavaScript errors were found before the release