HTML + CSS + JavaScript
- Fast
- Beautiful
- Usable
- Accessible
- Maintainable
- Localisable
- Automated
- Tested
Build things for 700k+ users and 100s of devs
Write code, review others' code I love deleting code
Mentor and support other devs
Make decisions with:
- Designers
- Other developers
- QAs
- Product Owners / Managers
- Easy to learn, hard to master
- Fast feedback
- Tangible/visual
- Fun
- The user controls browser, device, dimensions*
- Framework choices & pace-of-change*
- Available technologies*
- Changing platform*
- Browser variations
* Depending on your PoV
Chrome's are probably the best Very useful skill to have
Hypertext Markup Language
A set of elements for describing documents and relationships between them.
<!DOCTYPE html>
<html lang="en-NZ">
<head>
<meta charset="utf-8">
<title>Summer of Tech</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>
<a href="https://summeroftech.co.nz/">Summer of Tech</a>
</h1>
<p>Hi</p>
</body>
</html>
Check out a reference like MDN (not W3Schools!)
Following the spec is pretty straightforward
span
and div
are generic elements to use when there's not a specific element to use
(so they tend to be used a lot by JavaScript libraries when creating custom controls)
#marketing
New HTML, CSS & JavaScript features that make the web a better platform for writing applications.
CSS is easy
... and that makes it really hard
body {
font-family: Arial, Helvetica, sans-serif;
background-color: #fff;
color: #333;
}
p {
font-style: italic;
}
#thebest {
text-decoration: underline;
text-transform: uppercase;
}
.snazzy {
color: pink !important;
font-weight: bold;
}
Ugh
!important > inline > id > class > element
<p id="thebest" class="snazzy" style="padding-left: 20px;">
What is even happening?
</p>
- Sass
- LESS
- Rework
- PostCSS
- cssnext
$primary-color: #333;
body {
color: $primary-color;
}
@import "components/button";
@import "components/modal";
.foo {
color: fuschia;
}
.calendar {
border: 1px solid #555;
.calendar-day {
border: 1px solid #555;
color: blue;
font-size: 14px;
}
}
.foo {
background: linear-gradient(to bottom right, #333, #0c0);
}
=>
.foo {
background: -webkit-linear-gradient(top left, #333, #0c0);
background: linear-gradient(to bottom right, #333, #0c0);
}
And when the unprefixed form is universally supported autoprefixer will stop generating that rule
We thought CSS pre-processors were the hotness, but...
.nesting {
.stuff {
.is-easy {
color: black;
&.dangerous {
color: blue;
}
}
}
}
=>
.nesting .stuff .is-easy {
color: black;
}
.nesting .stuff .is-easy.dangerous {
color: blue;
}
When writing CSS for big projects, it’s the stuff outside the braces that counts...
-- Harry Roberts, http://csswizardry.com
body {} /* Base styles */
.layout-sidebar {} /* .layout-{name} */
.modal {} /* .{moduleName} */
.modal--header {} /* .{moduleName}--{subComponent} */
.button {} /* .{moduleName} */
.button-is-disabled {} /* .{moduleName}-is-{stateName} */
.button-default {} /* .{moduleName}-{subModule} */
.button-primary {} /* .{moduleName}-{subModule} */
<div class="modal">
<!-- .modal--header is a subcomponent -->
<div class="modal--header">Modal</div>
<div class="modal--body">
...
</div>
<div class="modal--footer">
<!-- .button-primary is a submodule -->
<button type="button" class="button button-primary">Save</button>
<button type="button" class="button button-cancel">Cancel</button>
</div>
</div>
By following strong conventions and minimising specificity, naming conventions keep your CSS more maintainable.
CSSLint is also a thing.
- Still some differences
IEEdge has been catching up- User agent strings are easy to fake
- Feature detection (e.g. Modernizr)
It used to be much much worse.
Any application that can be written in JavaScript, will eventually be written in JavaScript.
-- Jeff Atwood, http://blog.codinghorror.com/
By many measures the world's most popular programming language.
- Created in 10 days
- Released in 1995
- Renaissance started around 2006-2007
- Rise of Node.js from 2010-2011
- In the browser allows you to change HTML and the CSS applied after page load
- BTW, it's single threaded & asynchronous
#marketing
More like Scheme than Java
No block scope (until ES6's const
and let
)
Dynamic types and type coercion
this
is weird
You can do OO, but it's more fun and powerful to work with functions (IMO)
JavaScript is flexible so it's easy to write Ruby-style, Java-style, whatever-style code.
Don't do that. Or if you really want to consider a language that compiles to JavaScript.
TypeScript / Scala.js / ClojureScript / Dart / etc
JavaScript
function square (n) {
return n * n;
}
var input = [1, 2, 3, 4, 5];
var result = [];
var i;
for (i = 0; i < input.length; i++) {
result.push(square(input[i]));
}
var input = [1, 2, 3, 4, 5];
var result = input.map(function (n) {
return n * n;
});
const input = [1, 2, 3, 4, 5];
const result = input.map(n => n * n);
var input:number[] = [1, 2, 3, 4, 5];
var result = input.map((n: number) => {
return n * n;
});
// find an element in the document
const el = document.getElementById('content');
// listen to events on that element
el.addEventListener('click', function (e) {
e.preventDefault();
// modify that element somehow (e.g. changing styling)
el.classList.add('link-is-clicked');
});
Involves adding role
and aria
attributes to elements to describe them
<div>
An alert <button>X</button>
</div>
<div role="alert">
An alert <button aria-label="Close">X</button>
</div>
or
It's used in production by PayPal, eBay, LinkedIn, Walmart, Yahoo!, Uber, Trello, New York Times, News Corp and many others.
In Java:
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public static void main(String[] args) throws IOException {
String data = new String(Files.readAllBytes(Paths.get("data.txt")));
// do stuff with data here
}
In Node.js:
const fs = require('fs');
fs.readFile('data.txt', function(err, data) {
if(err) {
// handle error here
return;
}
// do stuff with data here
});
console.log('Do more stuff');
In Node.js with promises:
const readFile = require('bluebird').promisify(require('fs').readFile);
readFile('data.txt').then(function(data) {
// do stuff with data here
}).catch(function(err) {
// handle error here
});
console.log('Do more stuff');
- jQuery for DOM normalisation
- Underscore for utility fns
- React
- Backbone
- Angular / Angular 2
- Ember
Massive ecosystem, with lots of options.
Today it's less about protecting you from browser variation, more about how to structure applications.
import React from 'react';
function Button(props) {
return (
<button type={props.type}>{props.children}</button>
);
}
Button.propTypes = {
type: React.propTypes.string;
};
Button.defaultProps = {
type: 'button'
};
- Nested dependencies (no conflicts)
- Favors dynamic resolution
- Great with node; use with care for browser bundles
- Flattened dependencies (you resolve conflicts)
- Favors static resolution
- Good for bundling front-end code for browsers
The secret to building large apps is never build large apps. Break your applications into small pieces. Then, assemble those testable, bite-sized pieces into your big application.
-- Justin Meyer, JavaScriptMVC
Hypertext Transfer Protocol
1991 - v 0.9 1996 - v 1.0 1999 - v 1.1 2015 - v 2.0
Clients make requests to servers
Servers provide responses to clients
GET / POST / DELETE / PUT / PATCH / HEAD / OPTIONS
200 OK
301 Moved Permanently
304 Not Modified
400 Bad Request
404 Not Found
418 I'm a teapot (RFC 2324)
500 Internal Server Error
GET / HTTP/1.1
Host: www.summeroftech.co.nz
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: user-agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-NZ,en;q=0.8,en-US;q=0.6
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Length:5285
Content-Type: text/html; charset=UTF-8
Date: Tue, 17 May 2016 04:14:53 GMT
Host-Header: 192fc2e7e50945beb8231a492d6a8024
Link: <https://summeroftech.co.nz/wp-json/>; rel="https://api.w.org/", <https://wp.me/P6yDxo-yD>; rel=shortlink
Server: nginx
Vary: Accept-Encoding
X-Pingback: https://www.summeroftech.co.nz/xmlrpc.php
X-Proxy-Cache: MISS
<!doctype html>
...
const button = document.getElementById('sendButton');
sendButton.addEventListener('click', function (e) {
const request = new XMLHttpRequest();
request.open('GET', '/my/url');
request.onload = function() {
if (this.status >= 200 && this.status < 400) {
// Success!
var data = JSON.parse(this.response);
} else {
// We reached our target server, but it returned an error
}
};
request.onerror = function() {
// There was a connection error of some sort
};
request.send();
});
Apache / IIS / Nginx / Node / Tomcat / etc
Backends decoupled from front-ends Deploy independently Communicate via defined contracts (APIs) Back End for Front-Enders (proxies for transformation or rendering)
Transpiling, combining, linting, testing, measuring, etc. all that code needs tools.
Node = evented I/O (reading/writing to/from file system, std in/out, etc.).
Build little CLI tools is really easy ...
Node runs fast! Starting up Node is way cheaper than starting up a JVM.
Tools like Grunt, Gulp and Yeoman make task automation and project scaffolding easier.
Today's hot drama (still!?)
Web means the best reach, best device support, but you have to work harder.
Loads of "native" apps use web views for parts of their app.
It's not a binary choice and web technology makes it easy to try something.
- Single Page Applications*
- Bigger, more ambitious apps
- Smaller, more fine-grained modules
- Mainstreaming of functional programming
- Isomorphic apps
- Cloud infrastructure / platform-as-a-service
* we're sort of there now, but there is still some resistance
Immutability (we do it with Strings already)
Referential transparency
Testability
Predictability
- Meetups (AkJS, Auckland CSS)
- Conferences
- Github
- npm
- Social Media
- Podcasts
A Baseline for Front-End (JS) Developers Eloquent JavaScript Mostly Adequate Guide to JS Functional Programming Caching Tutorial for Web Authors and Webmasters
- JavaScript Jabber - http://devchat.tv/js-jabber/
- CodePen - http://codepen.io
- ES6Fiddle - http://www.es6fiddle.net
- Babel - https://babeljs.io
- ESLint - http://eslint.org
- http://nodeschool.io
@ivanandsickle