SlideShare a Scribd company logo
berlin amsterdam san francisco stuttgart
edenspiekermann_
Hardboiled Front End
Development
Found.ation talk
10th June 2014
Hardboiled Front End Development 10.06.2014edenspiekermann_
Introduction
Web Developer at Edenspiekermann.
!
Previously:
– Head of Design @ DailySecret.com.
– Head of Front End @ Liberis Publications.
!
Enjoys:
– CSS architecture.
– Refactoring code.
2
Hardboiled Front End Development 10.06.2014edenspiekermann_
Contents
1. CSS Architecture
–OOCSS. Design modules, not pages.
–BEM. Protecting scope. Hacking CSS.
–Sass. Enabling modularity. Pitfalls of extending and using mixins.
–Living Styleguides. Keeping the mess observable.
–Best Practices. Class prefixes, shame.css, z-index.css.
!
2. Javascript Modularity
–Modularity. Breaking the $(document).ready long file into modules.
–Module Tools. Including functionality on demand with requireJS.
–Automating tasks. Automating with Grunt and managing packages with Bower.
–Frameworks. Angular, Backbone, a very quick overview.
–Little useful tools. Backbone.wreqr, waypoints, owl carousel.
3
edenspiekermann_
CSS ARCHITECTURE
Hardboiled Front End Development 10.06.2014edenspiekermann_
CSS Architecture
CSS Advantages:
– Fast, quick to put something out.
– Small learning curve.
– Easy to override defaults.
!
Problems with CSS:
– All the above :-).
– No inherent modularity.
– No scope.
– Specificity.
5
edenspiekermann_
Think Modular
7
8
9
10
edenspiekermann_
Tools for modularity:
– SMACSS
– OOCSS
edenspiekermann_
Hardboiled Front End Development 10.06.2014edenspiekermann_
CSS Architecture
!
– Decouple Structure from Skin.
– Modifier classes.
– File structuring flexibility.
– Tackle Specificity issue (completely).
14
SMACSS
✓
✓
×
×
OOCSS
✓
×
✓
×
edenspiekermann_
What about specificity?
edenspiekermann_
http://designshack.net/articles/css/what-the-heck-is-css-specificity/
edenspiekermann_
http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html
edenspiekermann_
http://cssspecificity.com/
Hardboiled Front End Development 10.06.2014edenspiekermann_
body {!
font-size: 100%;!
font-family: Georgia, serif;!
}!
!
.o-chosen-select-box.chosen-
container,.m-font-
autocomplete{display:inline-
block;position:relative;vertical-
align:middle}.o-chosen-select-
box .chosen-single,.m-font-
autocomplete__input{background-
color:#f9f8f3;color:#262626;-webkit-box-
sizing:border-box;-moz-box-sizing:border-box;box-
sizing:border-box;border:4px solid
#fff;display:block;cursor:pointer;height:2.5em;line-
height:1.25em;padding:0 2.125em;-webkit-transition:background-
color 150ms,border-color 150ms;-moz-transition:background-color
150ms,border-color 150ms;!
.l-modal__tooltip__pane{z-index:30}.o-error{z-index:10}.o-
pulldown-panel__list{z-index:10}.l-tryout-page__canvas{z-index:
1}.l-tryout-page__header{z-index:30}.m-tryout-
textblock__action{z-index:20}.m-tryout-
textblock__editable{z-index:20}.m-tryout-
textblock__placeholder{z-index:10}.m-font-
autocomplete__dropdown,.o-chosen-select-
box{z-index:40}.l-tryout-page__template-
links,.l-tryout-page__bgimage-info{z-
index:50}.l-tryout-page__meta-links{z-
index:10000}.m-tryout-template-links
—centered{z-index:10}!
!
#footer .left-column .article
ul.links > li a img {!
border-color: #0A0;!
}!
CSS Architecture
Scientifically proven fact: we can’t keep track of
specificity throughout a CSS document.
19
Hardboiled Front End Development 10.06.2014edenspiekermann_
.o-square {!
height: 100px;!
width: 100px;!
}!
!
.o-square--black {!
background-color: black;!
}!
!
.o-square--green {!
background-color: green;!
}!
!
.o-square__inner-circle {!
border-radius: 100%;!
}!
!
.o-square__inner-circle--blue {!
background-color: blue;!
}!
CSS Architecture
Enter BEM.
– BEM stands for Block Element Modifier.
– Works like this: .block _ _ element - - modifier
– Self explanatory in both HTML & CSS.
– Shields object’s scope.
!
Things to remember:
– Never nest selectors (to ensure specificity == 1).
– Always & only, use classes.
– One object per file.
20
edenspiekermann_
Living Styleguides
Hardboiled Front End Development 10.06.2014edenspiekermann_
CSS Architecture
Advantages:
– Nice overview of all your objects.
– Enforces good practices.
– Enhances developer — designer collaboration.
– Helpful for context free development.
!
Challenges:
– Hard to initially set up.
– If not set up correctly, can have dulicate views in production & styleguide.
– Same object, different data issues.
!
Tools:
– https://github.com/kneath/kss
– http://livingstyleguide.org
– http://kaleistyleguide.com/
22
Hardboiled Front End Development 10.06.2014edenspiekermann_
gem install kss
CSS Architecture
Setting up KSS.
– Install gem.
23
Hardboiled Front End Development 10.06.2014edenspiekermann_
@styleguides = Kss::Parser.new(“/
public/css“)!
CSS Architecture
Setting up KSS.
– Install gem.
– Parse CSS folder into an object.
24
Hardboiled Front End Development 10.06.2014edenspiekermann_
CSS Architecture
Setting up KSS.
– Install gem.
– Parse CSS folder into an object.
– Iterate object in view.
25
- @styleguides.each do |styleguide|!
- [...]!
Hardboiled Front End Development 10.06.2014edenspiekermann_
/*!
The global button object.!
!
.button - Primary button.!
.button--green - Green variation.!
!
Styleguide 1.0 Button!
*/!
!
.button {!
height: 20px;!
text-align: center;!
width: 100px;!
}!
!
.button--green {!
background-color: green;!
}!
CSS Architecture
Setting up KSS.
– Install gem.
– Parse CSS folder into an object.
– Iterate object in view.
– Use the magic KSS syntax.
26
edenspiekermann_
Automating with Sass.
Hardboiled Front End Development 10.06.2014edenspiekermann_
CSS Architecture
Sass enables:
– Modular file structure with @import globbing.
– Eliminating inconsistencies. Vars for colours, typographic rythm units,
breakpoints, animation durations.
!
Pitfalls:
– “Mixins” print content inside of rule. Duplicate content.
– “Extends” group selectors where used. Rules are moved out of intended
place, watch out for split CSS files.
– Slow compiling of too many files, in Rails. Use libsass.
28
edenspiekermann_
Tips and Tricks.
Hardboiled Front End Development 10.06.2014edenspiekermann_
CSS Architecture
Tips:
– Helpful to prefix classes (“o-“, “l-“, “m-“), that way you recognize their
type in markup.
– Prefix JS hooks with “js-“. That way HTML/CSS restructuring doesn’t
affect javascript functionality.
– Use “is-” for dynamic states, induced by JS. For different kinds of states,
use BEM modifiers.
– Put all rushed code in shame.css. Always write reason of inclusion in
comments.
– Keep all z-index values in z-index.css and always use increments of 10 or
more.
30
edenspiekermann_
Ddddddemo
CSS Architecture
next.fontshop.com
edenspiekermann_
JS MODULARITY
Hardboiled Front End Development 10.06.2014edenspiekermann_
$(document).ready(function() {!
!
$(window).on('resize', resizeHandler);!
app.windowWidth = $window.width();!
app.windowHeight = $window.height();!
!
$(window).on("resizestart", function(){!
app.vent.trigger('fs:resize-start',
app.windowWidth, app.windowHeight);!
}).on("resizestop", function(){!
app.vent.trigger('fs:resize-stop',
app.windowWidth, app.windowHeight);!
});!
!
//Scrolling event, debounced at 500ms!
$(window).on("scroll", function(){!
var scrollFunc = _.debounce(function()
{!
app.vent.trigger('fs:scroll', $
(this).scrollTop());!
}, 500);!
scrollFunc();!
});!
!
// Show the targeted offscreen panel by
emitting the offscreen-panel:show event.!
// Creates one offscreen panel if it
doesn't exist already (as in editor or
languages list)!
$(document).on('click', ".js-show-
offscreen-panel, .js-family-finder-
trigger", function(event){!
Breaking long script files into chunks
Traditional approach: one long file
– Variable scope problems.
– Duplicate logic.
– Error prone.
– Impossible to maintain.
33
edenspiekermann_
Axiom:
Projects will ALWAYS scale.
https://www.flickr.com/photos/astrid/2583356797
Hardboiled Front End Development 10.06.2014edenspiekermann_
...!
!
<script src="jquery.js"></script>!
<script src="module1.js"></script>!
<script src="module2.js"></script>!
<script src="module3.js"></script>!
!
</body>!
</html>!
Breaking long script files into chunks
Alternative approach: Split & Include manually
– Too much manual labour.
– How do you handle common dependencies?
– Conflicts in the global object.
– Order of loading is important.
35
Hardboiled Front End Development 10.06.2014edenspiekermann_
define([
Breaking long script files into chunks
Better approach: Modularize everything
– Create a new file and define a module.
36
Hardboiled Front End Development 10.06.2014edenspiekermann_
define([!
"jquery",!
"jquery-ui"!
],!
function ($, jqueryUI) {!
Breaking long script files into chunks
Better approach: Modularize everything
– Create a new file and define a module.
– State its dependencies.
37
Hardboiled Front End Development 10.06.2014edenspiekermann_
define([!
"jquery",!
"jquery-ui"!
],!
function ($, jqueryUI) {!
!
var init = function (options) {!
//...implement logic!
};!
!
init(options);!
!
});!
Breaking long script files into chunks
Better approach: Modularize everything
– Create a new file and define a module.
– State its dependencies.
– Implement your logic.
38
Hardboiled Front End Development 10.06.2014edenspiekermann_
JS Module Creation Tools
– requireJS. http://requirejs.org
– Browserify. http://browserify.org
– Webpack. http://webpack.github.io
39
edenspiekermann_
Automating your workflow
with off-browser JS.
Hardboiled Front End Development 10.06.2014edenspiekermann_
module.exports = function(grunt) {!
!
// Load libs!
grunt.loadNpmTasks('grunt-watch');!
grunt.loadNpmTasks('grunt-jshint');!
grunt.loadNpmTasks('grunt-requirejs');!
!
// Project configuration.!
grunt.initConfig({!
pkg: '<json:package.json>',!
jshint: {!
options: {!
curly: true,!
eqnull: true,!
browser: true,!
sub: true,!
boss: true!
}!
}!
!
// Define task.!
grunt.registerTask('syntax',
['jshint:src']);};!
Automating tasks with Grunt (http://gruntjs.com)
Things you can do:
– Get immediate feedback on syntax errors.
– Live reload project.
– Minify, uglify, pack code.
– Also, use requireJS optimizer.
– libSass. Blazingly fast Sass compilation.
– Image compression.
–Control everything from one config file: gruntfile.js
!
– Alternative: Gulp (http://gulpjs.com). Lot of buzz lately.
41
Hardboiled Front End Development 10.06.2014edenspiekermann_
{!
"name": "Fontshop Relaunch",!
"version": "1",!
"dependencies": {!
"fittext": "",!
"jquery": "1.11",!
"underscore": "",!
"backbone": "",!
"backbone.wreqr": "",!
"backbone.marionette": "",!
"modernizr": "",!
"picturefill": "",!
"jquery-waypoints": "",!
"jquery-sortable": "",!
"OwlCarousel": "",!
"jasmine.async": "",!
"angular": "",!
"angular-chosen-localytics": "",!
"angular-local-storage": "",!
"ng-clip": "",!
"zeroclipboard": ""!
}!
}!
Manage Dependencies with Bower (http://bower.io)
Things you can do:
– Manage dependencies from one file.
– You can specify version of scripts.
– You can change folder (to fit your folder structuring).
!
Things you can’t do:
– Include in page automatically. Use requireJS for
that :).
42
A wee bit of JS frameworks & tools.
edenspiekermann_
Hardboiled Front End Development 10.06.2014edenspiekermann_
Backbone and Angular in Fontshop.
1. Backbone
– FS wasn’t an SPA. Used Backbone as a structuring tool for our JS modules.
– Helpful events object, this.$(“…”) selector, initializers.
– Create multiple instances easily.
– Enforces good OO practices.
!
2. Angular
– Used it in the tryout (http://next.fontshop.com/tryout) section.
– No boilerplate code.
– Provides one point of change (Model).
– Very quick to set functionality up.
44
Hardboiled Front End Development 10.06.2014edenspiekermann_
Some small favorite scripts :)
Backbone.wreqr (https://github.com/marionettejs/backbone.wreqr)
– True events based apps.
– Enable true modularity.
!
Waypoints (http://imakewebthings.com/jquery-waypoints)
– No more scrolling window, object, offset calculations.
– Also, sticky headers, easily done.
!
owlCarousel (http://www.owlgraphic.com/owlcarousel)
– Touch based (draggable).
– Responsive be default.
– Uses CSS 3D transforms, where possible.
!
45
berlin amsterdam san francisco stuttgart
edenspiekermann_
Thank you.
Spiros Martzoukos, Web Developer
tw @martzoukos
T +49 157 84340808
!
s.martzoukos@de.edenspiekermann.com
www.edenspiekermann.com

More Related Content

What's hot

Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Deepak Sharma
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web Design
Debra Shapiro
 
State of jQuery June 2013 - Portland
State of jQuery June 2013 - PortlandState of jQuery June 2013 - Portland
State of jQuery June 2013 - Portland
dmethvin
 
jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013
dmethvin
 
CSS Lessons Learned the Hard Way (Generate Conf)
CSS Lessons Learned the Hard Way (Generate Conf)CSS Lessons Learned the Hard Way (Generate Conf)
CSS Lessons Learned the Hard Way (Generate Conf)Zoe Gillenwater
 
The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013
Bastian Grimm
 
stickyHeader.js
stickyHeader.jsstickyHeader.js
stickyHeader.js
Russell Heimlich
 
Improving the Responsive Web Design Process in 2016
Improving the Responsive Web Design Process in 2016Improving the Responsive Web Design Process in 2016
Improving the Responsive Web Design Process in 2016
Cristina Chumillas
 
Be German About Your Frontend
Be German About Your FrontendBe German About Your Frontend
Be German About Your FrontendArush Sehgal
 
Tutorial to develop build files using ANT
Tutorial to develop build files using ANTTutorial to develop build files using ANT
Tutorial to develop build files using ANT
ravireddy76
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and Techniques
Vitaly Friedman
 
Tek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJSTek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJS
Pablo Godel
 
Responsive Web Design: Tips and Tricks
Responsive Web Design: Tips and TricksResponsive Web Design: Tips and Tricks
Responsive Web Design: Tips and Tricks
Gautam Krishnan
 
HTTP 2.0 - Web Unleashed 2015
HTTP 2.0 - Web Unleashed 2015HTTP 2.0 - Web Unleashed 2015
HTTP 2.0 - Web Unleashed 2015
dmethvin
 
Levent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & PolymerLevent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & Polymer
Erik Isaksen
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle Story
Kon Soulianidis
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
David Amend
 
Rapid Testing, Rapid Development
Rapid Testing, Rapid DevelopmentRapid Testing, Rapid Development
Rapid Testing, Rapid Development
mennovanslooten
 
Vue js for beginner
Vue js for beginner Vue js for beginner
Vue js for beginner
Chandrasekar G
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Dirk Ginader
 

What's hot (20)

Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web Design
 
State of jQuery June 2013 - Portland
State of jQuery June 2013 - PortlandState of jQuery June 2013 - Portland
State of jQuery June 2013 - Portland
 
jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013
 
CSS Lessons Learned the Hard Way (Generate Conf)
CSS Lessons Learned the Hard Way (Generate Conf)CSS Lessons Learned the Hard Way (Generate Conf)
CSS Lessons Learned the Hard Way (Generate Conf)
 
The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013
 
stickyHeader.js
stickyHeader.jsstickyHeader.js
stickyHeader.js
 
Improving the Responsive Web Design Process in 2016
Improving the Responsive Web Design Process in 2016Improving the Responsive Web Design Process in 2016
Improving the Responsive Web Design Process in 2016
 
Be German About Your Frontend
Be German About Your FrontendBe German About Your Frontend
Be German About Your Frontend
 
Tutorial to develop build files using ANT
Tutorial to develop build files using ANTTutorial to develop build files using ANT
Tutorial to develop build files using ANT
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and Techniques
 
Tek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJSTek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJS
 
Responsive Web Design: Tips and Tricks
Responsive Web Design: Tips and TricksResponsive Web Design: Tips and Tricks
Responsive Web Design: Tips and Tricks
 
HTTP 2.0 - Web Unleashed 2015
HTTP 2.0 - Web Unleashed 2015HTTP 2.0 - Web Unleashed 2015
HTTP 2.0 - Web Unleashed 2015
 
Levent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & PolymerLevent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & Polymer
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle Story
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
 
Rapid Testing, Rapid Development
Rapid Testing, Rapid DevelopmentRapid Testing, Rapid Development
Rapid Testing, Rapid Development
 
Vue js for beginner
Vue js for beginner Vue js for beginner
Vue js for beginner
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
 

Similar to Hardboiled Front End Development — Found.ation

Death of a Themer
Death of a ThemerDeath of a Themer
Death of a Themer
James Panton
 
Responsive & Responsible: Implementing Responsive Design at Scale
Responsive & Responsible: Implementing Responsive Design at ScaleResponsive & Responsible: Implementing Responsive Design at Scale
Responsive & Responsible: Implementing Responsive Design at Scale
scottjehl
 
Building Performance - ein Frontend-Build-Prozess für Java mit Maven
Building Performance - ein Frontend-Build-Prozess für Java mit MavenBuilding Performance - ein Frontend-Build-Prozess für Java mit Maven
Building Performance - ein Frontend-Build-Prozess für Java mit Maven
Oliver Ochs
 
EnterJS 2015 - Continuous Integration for Frontend Code
EnterJS 2015 - Continuous Integration for Frontend CodeEnterJS 2015 - Continuous Integration for Frontend Code
EnterJS 2015 - Continuous Integration for Frontend Code
Marcel Birkner
 
RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side Components
Sven Wolfermann
 
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
Eric Carlisle
 
Front End Workflow
Front End WorkflowFront End Workflow
Front End Workflow
Matt Bailey
 
CSMess to OOCSS: Refactoring CSS with Object Oriented Design
CSMess to OOCSS: Refactoring CSS with Object Oriented DesignCSMess to OOCSS: Refactoring CSS with Object Oriented Design
CSMess to OOCSS: Refactoring CSS with Object Oriented Design
Kate Travers
 
Team styles
Team stylesTeam styles
Team styles
nathanscott
 
Introducing grunt, npm and sass
Introducing grunt, npm and sassIntroducing grunt, npm and sass
Introducing grunt, npm and sass
priyanka1452
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
tdc-globalcode
 
CSS Workflow. Pre & Post
CSS Workflow. Pre & PostCSS Workflow. Pre & Post
CSS Workflow. Pre & Post
Anton Dosov
 
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style GuidesAdvanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Aidan Foster
 
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 ThemeCreating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
Acquia
 
CSS Architecture - JSIL.pdf
CSS Architecture - JSIL.pdfCSS Architecture - JSIL.pdf
CSS Architecture - JSIL.pdf
JonDan6
 
以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角
Mei-yu Chen
 
Responsive Design from problem to production
Responsive Design from problem to productionResponsive Design from problem to production
Responsive Design from problem to production
David Douglas
 
Web Frontend development: tools and good practices to (re)organize the chaos
Web Frontend development: tools and good practices to (re)organize the chaosWeb Frontend development: tools and good practices to (re)organize the chaos
Web Frontend development: tools and good practices to (re)organize the chaos
Matteo Papadopoulos
 

Similar to Hardboiled Front End Development — Found.ation (20)

Death of a Themer
Death of a ThemerDeath of a Themer
Death of a Themer
 
Responsive & Responsible: Implementing Responsive Design at Scale
Responsive & Responsible: Implementing Responsive Design at ScaleResponsive & Responsible: Implementing Responsive Design at Scale
Responsive & Responsible: Implementing Responsive Design at Scale
 
Building Performance - ein Frontend-Build-Prozess für Java mit Maven
Building Performance - ein Frontend-Build-Prozess für Java mit MavenBuilding Performance - ein Frontend-Build-Prozess für Java mit Maven
Building Performance - ein Frontend-Build-Prozess für Java mit Maven
 
EnterJS 2015 - Continuous Integration for Frontend Code
EnterJS 2015 - Continuous Integration for Frontend CodeEnterJS 2015 - Continuous Integration for Frontend Code
EnterJS 2015 - Continuous Integration for Frontend Code
 
RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side Components
 
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
 
Front End Workflow
Front End WorkflowFront End Workflow
Front End Workflow
 
Css framework
Css frameworkCss framework
Css framework
 
Css framework
Css frameworkCss framework
Css framework
 
CSMess to OOCSS: Refactoring CSS with Object Oriented Design
CSMess to OOCSS: Refactoring CSS with Object Oriented DesignCSMess to OOCSS: Refactoring CSS with Object Oriented Design
CSMess to OOCSS: Refactoring CSS with Object Oriented Design
 
Team styles
Team stylesTeam styles
Team styles
 
Introducing grunt, npm and sass
Introducing grunt, npm and sassIntroducing grunt, npm and sass
Introducing grunt, npm and sass
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
 
CSS Workflow. Pre & Post
CSS Workflow. Pre & PostCSS Workflow. Pre & Post
CSS Workflow. Pre & Post
 
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style GuidesAdvanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
 
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 ThemeCreating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
 
CSS Architecture - JSIL.pdf
CSS Architecture - JSIL.pdfCSS Architecture - JSIL.pdf
CSS Architecture - JSIL.pdf
 
以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角
 
Responsive Design from problem to production
Responsive Design from problem to productionResponsive Design from problem to production
Responsive Design from problem to production
 
Web Frontend development: tools and good practices to (re)organize the chaos
Web Frontend development: tools and good practices to (re)organize the chaosWeb Frontend development: tools and good practices to (re)organize the chaos
Web Frontend development: tools and good practices to (re)organize the chaos
 

Recently uploaded

MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
ssuser7dcef0
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 

Recently uploaded (20)

MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 

Hardboiled Front End Development — Found.ation

  • 1. berlin amsterdam san francisco stuttgart edenspiekermann_ Hardboiled Front End Development Found.ation talk 10th June 2014
  • 2. Hardboiled Front End Development 10.06.2014edenspiekermann_ Introduction Web Developer at Edenspiekermann. ! Previously: – Head of Design @ DailySecret.com. – Head of Front End @ Liberis Publications. ! Enjoys: – CSS architecture. – Refactoring code. 2
  • 3. Hardboiled Front End Development 10.06.2014edenspiekermann_ Contents 1. CSS Architecture –OOCSS. Design modules, not pages. –BEM. Protecting scope. Hacking CSS. –Sass. Enabling modularity. Pitfalls of extending and using mixins. –Living Styleguides. Keeping the mess observable. –Best Practices. Class prefixes, shame.css, z-index.css. ! 2. Javascript Modularity –Modularity. Breaking the $(document).ready long file into modules. –Module Tools. Including functionality on demand with requireJS. –Automating tasks. Automating with Grunt and managing packages with Bower. –Frameworks. Angular, Backbone, a very quick overview. –Little useful tools. Backbone.wreqr, waypoints, owl carousel. 3
  • 5. Hardboiled Front End Development 10.06.2014edenspiekermann_ CSS Architecture CSS Advantages: – Fast, quick to put something out. – Small learning curve. – Easy to override defaults. ! Problems with CSS: – All the above :-). – No inherent modularity. – No scope. – Specificity. 5
  • 7. 7
  • 8. 8
  • 9. 9
  • 10. 10
  • 11.
  • 14. Hardboiled Front End Development 10.06.2014edenspiekermann_ CSS Architecture ! – Decouple Structure from Skin. – Modifier classes. – File structuring flexibility. – Tackle Specificity issue (completely). 14 SMACSS ✓ ✓ × × OOCSS ✓ × ✓ ×
  • 19. Hardboiled Front End Development 10.06.2014edenspiekermann_ body {! font-size: 100%;! font-family: Georgia, serif;! }! ! .o-chosen-select-box.chosen- container,.m-font- autocomplete{display:inline- block;position:relative;vertical- align:middle}.o-chosen-select- box .chosen-single,.m-font- autocomplete__input{background- color:#f9f8f3;color:#262626;-webkit-box- sizing:border-box;-moz-box-sizing:border-box;box- sizing:border-box;border:4px solid #fff;display:block;cursor:pointer;height:2.5em;line- height:1.25em;padding:0 2.125em;-webkit-transition:background- color 150ms,border-color 150ms;-moz-transition:background-color 150ms,border-color 150ms;! .l-modal__tooltip__pane{z-index:30}.o-error{z-index:10}.o- pulldown-panel__list{z-index:10}.l-tryout-page__canvas{z-index: 1}.l-tryout-page__header{z-index:30}.m-tryout- textblock__action{z-index:20}.m-tryout- textblock__editable{z-index:20}.m-tryout- textblock__placeholder{z-index:10}.m-font- autocomplete__dropdown,.o-chosen-select- box{z-index:40}.l-tryout-page__template- links,.l-tryout-page__bgimage-info{z- index:50}.l-tryout-page__meta-links{z- index:10000}.m-tryout-template-links —centered{z-index:10}! ! #footer .left-column .article ul.links > li a img {! border-color: #0A0;! }! CSS Architecture Scientifically proven fact: we can’t keep track of specificity throughout a CSS document. 19
  • 20. Hardboiled Front End Development 10.06.2014edenspiekermann_ .o-square {! height: 100px;! width: 100px;! }! ! .o-square--black {! background-color: black;! }! ! .o-square--green {! background-color: green;! }! ! .o-square__inner-circle {! border-radius: 100%;! }! ! .o-square__inner-circle--blue {! background-color: blue;! }! CSS Architecture Enter BEM. – BEM stands for Block Element Modifier. – Works like this: .block _ _ element - - modifier – Self explanatory in both HTML & CSS. – Shields object’s scope. ! Things to remember: – Never nest selectors (to ensure specificity == 1). – Always & only, use classes. – One object per file. 20
  • 22. Hardboiled Front End Development 10.06.2014edenspiekermann_ CSS Architecture Advantages: – Nice overview of all your objects. – Enforces good practices. – Enhances developer — designer collaboration. – Helpful for context free development. ! Challenges: – Hard to initially set up. – If not set up correctly, can have dulicate views in production & styleguide. – Same object, different data issues. ! Tools: – https://github.com/kneath/kss – http://livingstyleguide.org – http://kaleistyleguide.com/ 22
  • 23. Hardboiled Front End Development 10.06.2014edenspiekermann_ gem install kss CSS Architecture Setting up KSS. – Install gem. 23
  • 24. Hardboiled Front End Development 10.06.2014edenspiekermann_ @styleguides = Kss::Parser.new(“/ public/css“)! CSS Architecture Setting up KSS. – Install gem. – Parse CSS folder into an object. 24
  • 25. Hardboiled Front End Development 10.06.2014edenspiekermann_ CSS Architecture Setting up KSS. – Install gem. – Parse CSS folder into an object. – Iterate object in view. 25 - @styleguides.each do |styleguide|! - [...]!
  • 26. Hardboiled Front End Development 10.06.2014edenspiekermann_ /*! The global button object.! ! .button - Primary button.! .button--green - Green variation.! ! Styleguide 1.0 Button! */! ! .button {! height: 20px;! text-align: center;! width: 100px;! }! ! .button--green {! background-color: green;! }! CSS Architecture Setting up KSS. – Install gem. – Parse CSS folder into an object. – Iterate object in view. – Use the magic KSS syntax. 26
  • 28. Hardboiled Front End Development 10.06.2014edenspiekermann_ CSS Architecture Sass enables: – Modular file structure with @import globbing. – Eliminating inconsistencies. Vars for colours, typographic rythm units, breakpoints, animation durations. ! Pitfalls: – “Mixins” print content inside of rule. Duplicate content. – “Extends” group selectors where used. Rules are moved out of intended place, watch out for split CSS files. – Slow compiling of too many files, in Rails. Use libsass. 28
  • 30. Hardboiled Front End Development 10.06.2014edenspiekermann_ CSS Architecture Tips: – Helpful to prefix classes (“o-“, “l-“, “m-“), that way you recognize their type in markup. – Prefix JS hooks with “js-“. That way HTML/CSS restructuring doesn’t affect javascript functionality. – Use “is-” for dynamic states, induced by JS. For different kinds of states, use BEM modifiers. – Put all rushed code in shame.css. Always write reason of inclusion in comments. – Keep all z-index values in z-index.css and always use increments of 10 or more. 30
  • 33. Hardboiled Front End Development 10.06.2014edenspiekermann_ $(document).ready(function() {! ! $(window).on('resize', resizeHandler);! app.windowWidth = $window.width();! app.windowHeight = $window.height();! ! $(window).on("resizestart", function(){! app.vent.trigger('fs:resize-start', app.windowWidth, app.windowHeight);! }).on("resizestop", function(){! app.vent.trigger('fs:resize-stop', app.windowWidth, app.windowHeight);! });! ! //Scrolling event, debounced at 500ms! $(window).on("scroll", function(){! var scrollFunc = _.debounce(function() {! app.vent.trigger('fs:scroll', $ (this).scrollTop());! }, 500);! scrollFunc();! });! ! // Show the targeted offscreen panel by emitting the offscreen-panel:show event.! // Creates one offscreen panel if it doesn't exist already (as in editor or languages list)! $(document).on('click', ".js-show- offscreen-panel, .js-family-finder- trigger", function(event){! Breaking long script files into chunks Traditional approach: one long file – Variable scope problems. – Duplicate logic. – Error prone. – Impossible to maintain. 33
  • 34. edenspiekermann_ Axiom: Projects will ALWAYS scale. https://www.flickr.com/photos/astrid/2583356797
  • 35. Hardboiled Front End Development 10.06.2014edenspiekermann_ ...! ! <script src="jquery.js"></script>! <script src="module1.js"></script>! <script src="module2.js"></script>! <script src="module3.js"></script>! ! </body>! </html>! Breaking long script files into chunks Alternative approach: Split & Include manually – Too much manual labour. – How do you handle common dependencies? – Conflicts in the global object. – Order of loading is important. 35
  • 36. Hardboiled Front End Development 10.06.2014edenspiekermann_ define([ Breaking long script files into chunks Better approach: Modularize everything – Create a new file and define a module. 36
  • 37. Hardboiled Front End Development 10.06.2014edenspiekermann_ define([! "jquery",! "jquery-ui"! ],! function ($, jqueryUI) {! Breaking long script files into chunks Better approach: Modularize everything – Create a new file and define a module. – State its dependencies. 37
  • 38. Hardboiled Front End Development 10.06.2014edenspiekermann_ define([! "jquery",! "jquery-ui"! ],! function ($, jqueryUI) {! ! var init = function (options) {! //...implement logic! };! ! init(options);! ! });! Breaking long script files into chunks Better approach: Modularize everything – Create a new file and define a module. – State its dependencies. – Implement your logic. 38
  • 39. Hardboiled Front End Development 10.06.2014edenspiekermann_ JS Module Creation Tools – requireJS. http://requirejs.org – Browserify. http://browserify.org – Webpack. http://webpack.github.io 39
  • 41. Hardboiled Front End Development 10.06.2014edenspiekermann_ module.exports = function(grunt) {! ! // Load libs! grunt.loadNpmTasks('grunt-watch');! grunt.loadNpmTasks('grunt-jshint');! grunt.loadNpmTasks('grunt-requirejs');! ! // Project configuration.! grunt.initConfig({! pkg: '<json:package.json>',! jshint: {! options: {! curly: true,! eqnull: true,! browser: true,! sub: true,! boss: true! }! }! ! // Define task.! grunt.registerTask('syntax', ['jshint:src']);};! Automating tasks with Grunt (http://gruntjs.com) Things you can do: – Get immediate feedback on syntax errors. – Live reload project. – Minify, uglify, pack code. – Also, use requireJS optimizer. – libSass. Blazingly fast Sass compilation. – Image compression. –Control everything from one config file: gruntfile.js ! – Alternative: Gulp (http://gulpjs.com). Lot of buzz lately. 41
  • 42. Hardboiled Front End Development 10.06.2014edenspiekermann_ {! "name": "Fontshop Relaunch",! "version": "1",! "dependencies": {! "fittext": "",! "jquery": "1.11",! "underscore": "",! "backbone": "",! "backbone.wreqr": "",! "backbone.marionette": "",! "modernizr": "",! "picturefill": "",! "jquery-waypoints": "",! "jquery-sortable": "",! "OwlCarousel": "",! "jasmine.async": "",! "angular": "",! "angular-chosen-localytics": "",! "angular-local-storage": "",! "ng-clip": "",! "zeroclipboard": ""! }! }! Manage Dependencies with Bower (http://bower.io) Things you can do: – Manage dependencies from one file. – You can specify version of scripts. – You can change folder (to fit your folder structuring). ! Things you can’t do: – Include in page automatically. Use requireJS for that :). 42
  • 43. A wee bit of JS frameworks & tools. edenspiekermann_
  • 44. Hardboiled Front End Development 10.06.2014edenspiekermann_ Backbone and Angular in Fontshop. 1. Backbone – FS wasn’t an SPA. Used Backbone as a structuring tool for our JS modules. – Helpful events object, this.$(“…”) selector, initializers. – Create multiple instances easily. – Enforces good OO practices. ! 2. Angular – Used it in the tryout (http://next.fontshop.com/tryout) section. – No boilerplate code. – Provides one point of change (Model). – Very quick to set functionality up. 44
  • 45. Hardboiled Front End Development 10.06.2014edenspiekermann_ Some small favorite scripts :) Backbone.wreqr (https://github.com/marionettejs/backbone.wreqr) – True events based apps. – Enable true modularity. ! Waypoints (http://imakewebthings.com/jquery-waypoints) – No more scrolling window, object, offset calculations. – Also, sticky headers, easily done. ! owlCarousel (http://www.owlgraphic.com/owlcarousel) – Touch based (draggable). – Responsive be default. – Uses CSS 3D transforms, where possible. ! 45
  • 46. berlin amsterdam san francisco stuttgart edenspiekermann_ Thank you. Spiros Martzoukos, Web Developer tw @martzoukos T +49 157 84340808 ! s.martzoukos@de.edenspiekermann.com www.edenspiekermann.com