102
Large Scale CSS Refactoring at trivago @pistenprinz

Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Embed Size (px)

Citation preview

Page 1: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Large Scale CSS Refactoring at trivago

@pistenprinz

Page 2: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Ironman release picture

Crazy Guy

Talking to you right now

Does something with frontend at trivago

Loves giving presentations

U.Bolt

Performance Unicorn

Page 3: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

What is it?A description

Project Ironman was the technical migration of the trivago hotel search's existing CSS core to a pattern library based user interface.*

*) business translation for #refactorAllTheThings

Page 4: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 5: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Ironman - Tech ContextThe Big Picture

Page 6: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#1 Establish design and code consistencyIntroduce a Frontend / Design System into the trivago hotel search

Page 7: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#2 Improve code quality and maintainabilityReduce technical debt

Page 8: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#3 Provide base for modern & sustainable UI rebuildBuild modern applications fast

Page 9: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

The former Case StudyA Pattern Library and Atomic Design

Page 10: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

The old company pagesBuilt without Design Thinking and Atomic Design

Page 11: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

The relaunched site

Built with Design Thinking and Atomic Design

Page 12: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

The first RedesignsCompany Pages and Quality Test Intro Page

Page 13: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Where we come from

What happened since 2012

Page 14: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Specificity graph 2012

The specificity wall

Page 15: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 16: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 17: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 18: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 19: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

–Christian Bauer

„Zitat hier eingeben.“

Page 20: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Graph before ironman

Way better, but still …

peaks at the beginning of the stylesheet

Page 21: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 22: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Before Ironman

The Pain Points

Page 23: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#1 Sprites were out of controlWe built Frankenstein with Icons

Page 24: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 25: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#2 Creepy Render BugsNo, i don’t render your site

Page 26: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 27: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

#3 Too much CSSHow many Selectors do you use? ALL!

Page 28: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#4 Desktop first approachOh you poor mobile devices

Page 29: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#5 Inconsistency and missing StyleguideOr how to create fifty shades of grey or anything else

Page 30: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Code / Process Audits• IE7 support • Layout built on reset.css • too complex CSS structure

Page 31: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#6 Overly complex CSS/DOM structurediv, div, div, span, span, span

Page 32: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Ironman - the scope

The three disciplines

Page 33: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#1 Normalize.css incl. border-box switchReplace reset.css and remove content-box for box-sizing

Page 34: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#2 Mobile first switchRewrite all media queries

Page 35: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#3 Replace image sprites with SVGs and FallbackIcon solution based on Grunticon

Page 36: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Ironman - the oath

What we had to promise

Page 37: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Retain the existing Layout & Designintegrate the new CSS framework base which was developed with the Pattern Library without changing the appearance of the site

Page 38: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Ironman - technical details

What we had to refactor

Page 39: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#1 Refactor > 50k LOC of ScssRewrite / adapt the whole Scss Base

Page 40: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#2 Adapt dozens of templatesMarkup changes needed for the new architecture

Page 41: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#3 Keep IE8 supportYeah we still make money with IE8

Page 42: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#4 Remove all the Icons coming from spritesPrettify Frankenstein

Page 43: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#5 Extensive Device-TestingRe-Test the application on all possible device

Page 44: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#6 Do it four weeksTime is limited

Page 45: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Ironman - the business side

Management <3 refactoring. Not. </3

Page 46: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

How to tell management that you need 4 weeks of feature freeze and the User Interface will look exactly the same afterwards?Developer goes Marketing

Page 47: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Code / Process AuditsHow to tell management that you need you need 4 weeks of feature freeze and the User Interface will exactly look the same afterwards?

Page 48: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#1 Be a salesman- Sell it! Prove it! Show benefits!Argue!

Page 49: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#2 Do it in 3 weeks!Meet the deadline

Page 50: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#3 Don’t only think technically! Think like a business person

Page 51: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Ironman - the process

How to integrate such a project

Page 52: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#? How to integrate such a project into an existing process?Don’t harm the existing process

Page 53: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#? How to handle management expectation?How to keep management up to date

Page 54: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#? How to plan and estimate?#noEstimates

Page 55: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Ironman - Agility

Possible ways to enforce culture

Page 56: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#1 People over processThe Agile Manifesto told ya

Page 57: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#2 Commitment over estimation*Interested to know when you are done, or interested to be as fast as possible?*) only works if you meet the deadline

Page 58: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#3 Make progress transparent & involve everybodyUpdate the stakeholders as often as possible

Page 59: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

#4 Motivate people and let them be awesomeHire awesome people and get out of their way

Page 60: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Ironman - the numbers

People & processes

Page 61: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 62: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

The People One project team… and infinite supporters

Page 63: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

9 Front-End Devs

3 Designers2 QA

Release Engineer

Management

Back-End Devs

Performance Lead

UBolt UXBolt

Product Owner

Page 64: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

The (lean) Process 3 Meetings +17 Stand-Ups… and a Kanban board with 67 Post-Its and a slack-channel is all we needed

Page 65: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Ironman - the numbers

Code and Outcome

Page 66: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

889 commits in 3 weeks16 commits per hour #YOLO

Page 67: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

11973 LOC addedThat is new / changed code

Page 68: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

36668 LOC removedDelete all the things (CSS,HTML,JS)

Page 69: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

LOC from 52991 to 39755Removed nearly 25% of the Scss Base

Page 70: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Replaced 451 IconsInfinite Icons replaced with SVG Icons

Page 71: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

352 changed filesInfinite Icons replaced with SVG Icons

Page 72: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Code / Process Audits• Foundation built to move the UI Development to the next level • Better rendering performance on mobile • Shared knowledge and understanding throughout, between all developers and the entire design/product team

CSS Selectors Before and after

7009 vs 5605

Page 73: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Code / Process Audits• Foundation built to move the UI Development to the next level • Better rendering performance on mobile • Shared knowledge and understanding throughout, between all developers and the entire design/product team

CSS Rules Before and after

5817 vs 4870

Page 74: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Code / Process Audits• Foundation built to move the UI Development to the next level • Better rendering performance on mobile • Shared knowledge and understanding throughout, between all developers and the entire design/product team

CSS Declarations Before and after

13500 vs 11300

Page 75: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Showcase 1Desktop first vs. Mobile first

Page 76: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 77: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 78: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Showcase 2Sprite Wars vs. SVG beauty

Page 79: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 80: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)
Page 81: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Showcase 3HTTP Requests

Page 82: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Showcase 3HTTP requests

Page 83: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Showcase 3HTTP requests

Page 84: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

<3 Sorted the colorsEstablished and introduce a color palette

Page 85: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

trv-blue-light#3f9fc1

trv-red-light#d67763

trv-green-light#8cba3f

trv-green-lighter#b2d17f

trv-green-dark#4c7b00

trv-juri-light#697379

trv-juri-lighter#9ba2a6

trv-juri-lightest#ebeced

trv-blue-dark#005f81

trv-blue#007fad

trv-orange#f48f00

trv-red#c94a30

trv-orange-dark#b76b00

trv-orange-light#f6ab3f

trv-blue-lightest#e5f2f6

trv-red-lightest#f9ecea

trv-orange-lightest#fdf3e5

trv-red-dark#963724

trv-green#66a400

trv-juri#37454d

trv-juri-dark#293339

16

12 18

16

12

12

18

12

18

16

*

trv-juri-very-light#cdd0d2

trv-red-very-light#f1d1cb

trv-green-very-light#d8e8bf

trv-orange-very-light#fce3bf

trv-blue-very-light#bfdfea

trv-red-lighter#e4a49b

trv-orange-lighter#f9c780

trv-blue-lighter#7fbfd6

trv-green-lightest#eff5e5

Page 86: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

<3 Solved the icon chaosReplaced the image sprites with a SVG icon set

Page 87: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

description details infobig hotelconnect smiley heart towel star pictures

wifi spa beach breakfast pool pet golf tv family eco parking

bed_single bed_double bed_small couple universal home menu share edit

checkout checkin general rates

faq_circle faq info_circleinfo

arrow_right_circle arrow_left_circle arrow_down_circle arrow_up_circle arrow_right arrow_left arrow_down arrow_up tick exclamation x plus minus

image media bag chair team candy journalist news hoteltest plus_circle minus_circle x_circle filter

dashboard statistics hotel2 hotel travel2 travel booking hotelchain upload delete tick_circle exclamation_circle contact

profile info product history giveback lock calendar search publisher career comment download map

smiley_belowaverage smiley_satisfactory smiley_good smiley_verygood smiley_excellent smiley_belowaverage smiley_satisfactory smiley_good smiley_verygood smiley_excellent

level sort department

poi_citycentre poi_airport poi_sight poi_conference poi_harbor poi_mainstation poi_nature poi_nightlife poi_sports

filterreset join

thin

share2 movie call piechart diagram music multimedia

wifi spa beach breakfast pool pet golf tv family eco parking

bed_single bed_double bed_small couple universal home menu share edit

checkout checkin general rates description details infobig hotelconnect smiley heart towel star pictures

icn_profile icn_info icn_product icn_history icn_giveback icn_lock icn_calendar icn_search icn_publisher icn_career icn_comment icn_download icn_map

icn_dashboard icn_statistics icn_hotel2 icn_hotel icn_travel2 icn_travel icn_booking icn_hotelchain icn_upload icn_delete icn_tick_circle exclamation_circle contact

image media bag chair team candy journalist news hoteltest plus_circle minus_circle x_circle icn_filter

arrow_right_circle arrow_left_circle arrow_down_circle arrow_up_circle arrow_right arrow_left arrow_down arrow_up tick exclamation x plus minus

faq_circle faq info_circle info

smiley_belowaverage smiley_satisfactory smiley_good smiley_verygood smiley_excellentsmiley_belowaverage smiley_satisfactory smiley_good smiley_verygood smiley_excellent

level sort department

poi_citycentre poi_airport poi_sight poi_conference poi_harbor poi_mainstation poi_nature poi_nightlife poi_sports

join

thin

filterreset share2 movie call piechart diagram music multimedia

Page 88: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Graph before Ironman

Way better, but still …

peaks at the beginning of the stylesheet

Page 89: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Graph after Ironman

Improved curve

New CSS base

Adapted old UI components. Can now be easily rebuilt!

SVG

Page 90: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

The metricsA/B Test results

Page 91: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

The final result Lets celebrate and merge

Page 92: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Let’s go crazy

Page 93: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

RetrospectiveWhat we have achieved - High Level Summary

Page 94: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

<3 Foundation built to move the UI to the next levelSustainable base to continue UI rebuild

Page 95: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

<3 Better rendering performance on mobileNo more poor mobile devices

Page 96: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

<3 Shared knowledge and understanding Affects the developers and the entire design/product team

Page 97: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

<3 Optimized design-development process Atomic Design FTW

Page 98: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

<3 New coding guidelines and improved structure ITCSS, BEM, OOCSS, …

Page 99: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Moving fasterThe time after

Page 100: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

Faster Product IterationsOld version of the search result

Page 101: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

The new item elementNew version built with pattern lab upon new base

Page 102: Project Ironman - Large Scale Refactoring @trivago (JSUnconf 2016)

Christoph Reinartz - @pistenprinz

ThanksI’m done

Christoph Reinartz Team Lead UI/UX Engineering @pistenprinz