Slide 1

Slide 1 text

davidson fellipe front-end engineer at globo.com PRACTICAL GUIDE FOR FRONT-END DEVELOPMENT FOR DJANGO DEVS

Slide 2

Slide 2 text

- HTML ~ 2001 - front-end engineer - globo.com ~ 2010 - more about me at fellipe.com me

Slide 3

Slide 3 text

globo.com - 35 multidisciplinary teams using agile methodologies - large open source community - projects at opensource.globo.com

Slide 4

Slide 4 text

globo.com - 3 multidisciplinary teams - all engineers code for client side sports at globo.com

Slide 5

Slide 5 text

https://www.!ickr.com/photos/frontendbr/1691161875/sizes/o/ WHY FRONT-END?

Slide 6

Slide 6 text

94% of load time is related to client side (globoesporte.com/copa) http://gtmetrix.com/har.html?inputUrl=http://gtmetrix.com/reports/globoesporte.globo.com/7eqNM2Z1/net.harp&expand=true&validate=false

Slide 7

Slide 7 text

USER EXPERIENCE OPTIMIZED

Slide 8

Slide 8 text

http://www.reddit.com/r/javascript/comments/14zwpv/why_are_front_end_developers_so_high_in_demand_at/ WHY ARE FRONT END DEVELOPERS SO HIGH IN DEMAND AT STARTUPS IF FRONT END DEVELOPMENT IS RELATIVELY EASIER THAN OTHER FIELDS OF ENGINEERING?

Slide 9

Slide 9 text

CODE NEEDS TO WORK IN DIFFERENT ENVIRONMENTS

Slide 10

Slide 10 text

MULTIPLE BROWSERS MULTIPLE VERSIONS MULTIPLE RESOLUTIONS MULTIPLE DEVICES

Slide 11

Slide 11 text

HTML, CSS, JAVASCRIPT, FEATURE DETECTION, REPAINT, REFLOW, PRE-PROCESSORS, HTTP, CSRF, ANIMATIONS TIME FUNCTIONS, SVG, CANVAS, LOCALSTORAGE, WEBCOMPONENTS, XSS, WEBSOCKETS, SHADOW DOM, GRIDS SYSTEMS, SCHEMA.ORG, SEO... AND WHY NOT? DEPENDENCY MANAGEMENT, MVC FRAMEWORKS, TESTING, CODE QUALITY ANALYZERS, TASK RUNNERS, PERFORMANCE...

Slide 12

Slide 12 text

http://i1-news.softpedia-static.com/images/news2/Three-of-the-Windows-Users-Fears-and-Misconceptions-About-Linux-427770-2.jpg

Slide 13

Slide 13 text

http://i1-news.softpedia-static.com/images/news2/Three-of-the-Windows-Users-Fears-and-Misconceptions-About-Linux-427770-2.jpg

Slide 14

Slide 14 text

IT’S MUCH MORE THAN CONVERT JPG TO HTML

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

http:globoesporte.com

Slide 17

Slide 17 text

- how load the shields? - how to create this tabs? - what happens when a team is loaded? - how to request a new soccer team? - where to use WAI-ARIA?

Slide 18

Slide 18 text

+ combining elements

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

MAKE APPS!

Slide 21

Slide 21 text

app example - division of responsibilities - unit tests for each app - management and setup of dependencies using pypi - is difficult to separate when the apps are already in production together app product core app news app polls requirements.txt

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

our requirements - DRY - components - fonts and icons - similar interactions across site - possibility of themes - low speci"city of CSS

Slide 24

Slide 24 text

thinking in components

Normal Bold

read more HTML

Slide 25

Slide 25 text

organizing your app (ge)davidson ➜ .../ge_ui/static (master) $ tree |-fonts |---icons |---opensans |-img |---ge_ui |-----placeholder |-----sprites |-js |---ge_ui |---vendor |-scss |---ge_ui |---vendor TERMINAL

Slide 26

Slide 26 text

how blocks work? {% extends "core/delivery.html" %} {% block css_delivery %} {{ block.super }} {% endblock %} delivery.html TEMPLATE app core TEMPLATE app poll

Slide 27

Slide 27 text

DO MORE TEMPLATE TAGS

Slide 28

Slide 28 text

template tag # -*- coding: utf-8 -*- from django.template import Library register = Library() @register.inclusion_tag('components/dropdown.html') def ge_ui_dropdown(dropdown): return {'dropdown': dropdown} ge_ui_dropdown.is_safe = True register.filter(ge_ui_dropdown)

Slide 29

Slide 29 text

dropdown.html
{{dropdown.title}}
iterations

Slide 30

Slide 30 text

DO YOU WANT TO CREATE A UI LIB? NO, I DON’T!

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

CSS VS PREPROCESSORS

Slide 34

Slide 34 text

good parts - improve productivity - easy to work with modules - use of mixins, variables, selector inheritance and nesting

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

BAD PRACTICES WITH CSS, CAN BE MADE

Slide 40

Slide 40 text

doing evil with scss! .great-grandfather { .grandfather { .father { #wtf { color: #f60; } } } } .great-grandfather .grandfather .father #wtf { color: #f60; } /* why high specificity id? */ SCSS CSS

Slide 41

Slide 41 text

AUTOMATING TASKS

Slide 42

Slide 42 text

let’s use Grunt?

Slide 43

Slide 43 text

grunt.js - low learning curve - large number of plugins - huge open source community

Slide 44

Slide 44 text

I’ve got to con"gure node.js?

Slide 45

Slide 45 text

$ make grunt-con"g grunt-config: @if [ ! $$(which node) ]; then echo "✖ installing node..."; brew install node; else echo "node ✔"; fi @if [ ! $$(which npm) ]; then echo '✖ installing npm...'; sudo curl https://npmjs.org/install.sh -k | sh; else echo "npm ✔"; fi @if [ ! $$(which grunt) ]; then echo '✖ installing grunt...'; sudo npm install -g grunt-cli; else echo "grunt ✔"; fi @sudo npm i --save-dev MAKEFILE grunt-config: @if [ ! $$(which node) ]; then echo "✖ installing node..."; brew install node; else echo "node ✔"; fi @if [ ! $$(which npm) ]; then echo '✖ installing npm...'; sudo curl https://npmjs.org/install.sh -k | sh; else echo "npm ✔"; fi @if [ ! $$(which grunt) ]; then echo '✖ installing grunt...'; sudo npm install -g grunt-cli; else echo "grunt ✔"; fi @sudo npm i --save-dev MAKE

Slide 46

Slide 46 text

tasks - test runners - preprocessors - js / css lint - create sprites - concatenation

Slide 47

Slide 47 text

package .json { "name": "poll", "version": "0.0.1", "devDependencies": { "grunt": "~0.4.2", "grunt-contrib-jshint": "~0.6.5", "grunt-contrib-uglify": "~0.2.7", "grunt-contrib-watch": "~0.5.3", "load-grunt-tasks": "~0.2.0", "grunt-contrib-compass": "~0.6.0", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-copy": "~0.4.1", "grunt-shell": "~0.6.1" } } JS

Slide 48

Slide 48 text

Grunt"le .js module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file .readJSON('package.json'), pathBase: 'poll/static/poll/', pathSrc: '<%= pathBase %>src/', pathBuild: '<%= pathBase %>build/', compass: {}, uglify: {}, clean: {}, concat: {}, copy: {}, shell: {} }); require('load-grunt-tasks')(grunt); grunt.registerTask('build', ['compass:min','concat','clean','copy', 'uglify','shell']); }; JS

Slide 49

Slide 49 text

LET'S CREATE A CODING STANDARD?

Slide 50

Slide 50 text

standards - quotes, braces, semicolons - Space vs Tab - Single quote vs double quotes - nomenclatures for functions, Object Literal, conditional statement...

Slide 51

Slide 51 text

https://github.com/rwaldron/idiomatic.js/

Slide 52

Slide 52 text

https://github.com/airbnb/javascript

Slide 53

Slide 53 text

http://csslint.net/

Slide 54

Slide 54 text

PERFORMANCE

Slide 55

Slide 55 text

#everybodyloves

Slide 56

Slide 56 text

http://www.broofa.com/Tools/JSLitmus/

Slide 57

Slide 57 text

http://pitomba.org/

Slide 58

Slide 58 text

https://github.com/django-compressor/django-compressor

Slide 59

Slide 59 text

https://github.com/davidsonfellipe/keepfast/

Slide 60

Slide 60 text

http://browserdiet.com/

Slide 61

Slide 61 text

What impact performance? - low conversions - low engagement - high rejection rates

Slide 62

Slide 62 text

- fellipe.com/talks - github.com/davidsonfellipe - twitter.com/davidsonfellipe thankyou