Front End Best Practices: A Selection of Best Practices, Tips, Tricks & Good Advice For Today’s Front End Development. Practices mentioned in this presentation range from basic principles to more advanced tools and techniques. By Holger Bartel for WomenWhoCodeHK 23/07/2014
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
Front End Best Practices
1. FRONT END
BEST PRACTICES
Holger Bartel | @foobartel | WomenWhoCodeHK 23/07/2014
A Selection of Best Practices, Tips, Tricks & Good Advice For Today’s Front End Development
8. GOOD OLD TIP NO. 1:
VALIDATION
http://validator.w3.org
!
http://jigsaw.w3.org/css-validator/
9. Whenever possible, avoid superfluous parent
elements when writing HTML. Many times this
requires iteration and refactoring, but produces less
HTML.
REDUCING MARKUP
13. /*
apply
a
natural
box
layout
model
to
all
elements
*/
!
*,
*:before,
*:after
{
-‐moz-‐box-‐sizing:
border-‐box;
-‐webkit-‐box-‐sizing:
border-‐box;
http://www.paulirish.com/2012/box-sizing-border-box-ftw/
14. px is an absolute unit of measurement -
px units don't scale
!
em is not an absolute unit -
it is a unit that is relative to the currently
chosen font size.
PIXELS VS. EMS
15. body
{
font-‐size:62.5%;
}
h1
{
font-‐size:
2.4em;
}
/*
=24px
*/
p
{
font-‐size:
1.4em;
}
/*
=14px
*/
li
{
font-‐size:
1.4em;
}
/*
=14px?
*/
!
li
li
{
}
!
1.4em
=
14px
BUT
14
*
1.4
=
20
FONT SIZE COMPOUNDS
16. The em unit is relative to the font-size of the
parent, which causes the compounding issue.
!
The rem unit is relative to the root—or the
html—element.
REM == ROOT EM
49. IMAGES OFTEN ACCOUNT FOR
MOST OF THE DOWNLOADED
BYTES ON A PAGE.
!
OPTIMIZING YOUR IMAGES
CAN OFTEN YIELD LARGE BYTE
SAVINGS AND PERFORMANCE
IMPROVEMENTS.
62. Waiting for the DOM and CSSOM to build the render
tree.
!
Blocking JavaScript until the CSS file is downloaded
and parsed: the JavaScript may query the CSSOM
RENDER-BLOCKING
h ps://developers.google.com/speed/docs/insights/BlockingJS
63. Every request fetched inside of HEAD, will postpone
the rendering of the page!
LOAD JS AFTER CSS