prejss: the final point in the css war

83
PreJSS: the final point in the CSS war Denis Izmaylov Mar 15, 2017

Upload: denis-izmaylov

Post on 06-Apr-2017

39 views

Category:

Software


1 download

TRANSCRIPT

Page 1: PreJSS: the final point in the CSS war

PreJSS: the final point in the CSS war

Denis Izmaylov

Mar 15, 2017

Page 2: PreJSS: the final point in the CSS war

Denis Izmaylov1. Over 17 years of Software and Web

development experience

2. The last 7 years focused exclusively on Front-end and Web: 15+ projects,including React.js, SPA and high-load

3. Open Source contributor

4. Talks: HighLoad++ 2015, AgileDays 2016, DevConf 2016, React Amsterdam, etc

5. Regular speaker on MoscowJS

6. Few popular articles and interviewson Medium and Habrahabr

7. Events: Moscow Node.js Meetup, Moscow Kubernetes Meetup and this one

Page 3: PreJSS: the final point in the CSS war

Web and Mobile development services

Page 4: PreJSS: the final point in the CSS war

1. We develop Web, Mobile and DevOps projects for our customers

2. Global international market (EU, APAC, US, HK)

3. Most efficient and performant technologies

4. More than 20 talents engineers and designers

5. Remote-friendly

Page 5: PreJSS: the final point in the CSS war

Prerequisite Knowledge

1. SCSS

2. PostCSS

3. JSS

5

Page 6: PreJSS: the final point in the CSS war

Huge thanks to everyone in JavaScript community

who made those years better

Page 7: PreJSS: the final point in the CSS war

7

1994

Page 8: PreJSS: the final point in the CSS war

8

Better

1. Scripts in hypertext documents

2. XHR (aka AJAX)

3. Styling elements

Page 9: PreJSS: the final point in the CSS war

9

Draw UI in documents

Page 10: PreJSS: the final point in the CSS war

“It is a triumph of performance over semantics”

10

Page 11: PreJSS: the final point in the CSS war

Let’s hack Document Object Model

(DOM)

11

Page 12: PreJSS: the final point in the CSS war
Page 13: PreJSS: the final point in the CSS war

But

Page 14: PreJSS: the final point in the CSS war

Pure Applications

Page 15: PreJSS: the final point in the CSS war

Requirements are growing

Page 16: PreJSS: the final point in the CSS war

16

Page 17: PreJSS: the final point in the CSS war

Code refactoring and technical debts are expensive

Page 18: PreJSS: the final point in the CSS war

New abstractions to deliver changes faster

18

Page 19: PreJSS: the final point in the CSS war

More abstractions – more source code

Page 20: PreJSS: the final point in the CSS war

Split by scripts

20

Page 21: PreJSS: the final point in the CSS war

More requirements – more scripts

Page 22: PreJSS: the final point in the CSS war

Load order hell

Page 23: PreJSS: the final point in the CSS war

Split by scripts

Page 24: PreJSS: the final point in the CSS war

1. Require.js

2. AMD

3. CommonJS

4. Dependencies

5. Pre-build step

2009

Page 25: PreJSS: the final point in the CSS war

JavaScript bundles

Page 26: PreJSS: the final point in the CSS war

26

1. Modules

2. Images

3. Fonts

4. Data

5. CSS

JavaScript bundles

Page 27: PreJSS: the final point in the CSS war

27

1. Modules

2. Images

3. Fonts

4. Data

5. CSS

JavaScript bundles

Page 28: PreJSS: the final point in the CSS war

More requirements - more CSS

Page 29: PreJSS: the final point in the CSS war

New abstractions to deliver changes faster

29

Page 30: PreJSS: the final point in the CSS war

More abstractions - more source code

Page 31: PreJSS: the final point in the CSS war

CSS became scripts

31

1. Variables

2. Functions

3. Mixins

4. Templates

5. Nesting

6. etc

Page 32: PreJSS: the final point in the CSS war

32

Page 33: PreJSS: the final point in the CSS war

CSS formats hell

33

1. LESS

2. SASS/SCSS

3. Stylus

4. …

Page 34: PreJSS: the final point in the CSS war

There was long years of CSS preprocessors war

Page 35: PreJSS: the final point in the CSS war

SASS finally won

35

Page 36: PreJSS: the final point in the CSS war

SASS finally won

36

Monolithic

Page 37: PreJSS: the final point in the CSS war

2nd Generation

37

1. Rework/Styl

2. PostCSS

Page 38: PreJSS: the final point in the CSS war

PostCSS

38

Page 39: PreJSS: the final point in the CSS war

PostCSS

39

1. Parse CSS to AST/JSON tree

2. Apply plugins to this tree

3. Compile final tree to CSS

Page 40: PreJSS: the final point in the CSS war

PostCSS

40

1. Parse CSS to AST/JSON tree

2. Apply plugins to this tree

3. Compile final tree to CSS

• CSS powered by plugins

• CSS modules

Page 41: PreJSS: the final point in the CSS war

PostCSS

41

“Post-modern”

|

“after CSS”

Page 42: PreJSS: the final point in the CSS war

CSS in Applications

42

1. Build step

2. Build time

3. CSS is not about styling my documents

4. CSS is about UI and components

5. CSS is a script language

6. CSS is a part of your code

Page 43: PreJSS: the final point in the CSS war

Complexity

Page 44: PreJSS: the final point in the CSS war

44

Page 45: PreJSS: the final point in the CSS war

After PostCSS

45

1. Do not parse CSS.Define styles in JavaScript objects.

2. Do not use plugins for everything.Use plain functions instead.

3. Use default plugins presets, like Babel.

Page 46: PreJSS: the final point in the CSS war

— Seriously? CSS in JS?!

Page 47: PreJSS: the final point in the CSS war

2013, Facebook, React.js

47

Page 48: PreJSS: the final point in the CSS war

2013, Facebook, React.js

XML-like constructions in JavaScript code to explain

Components tree

48

Page 49: PreJSS: the final point in the CSS war

React covers HTML elements only *

Page 50: PreJSS: the final point in the CSS war

October 2014, JSS

Page 51: PreJSS: the final point in the CSS war

Noveber 2014, CSS-in-JS

Christopher Chedeau, Facebook

51

Page 52: PreJSS: the final point in the CSS war

React Native

52

Page 53: PreJSS: the final point in the CSS war

JSS is not about Inline Styles

Page 54: PreJSS: the final point in the CSS war

JSS generates a real CSS from JavaScript

Page 55: PreJSS: the final point in the CSS war

JSS notation

Page 56: PreJSS: the final point in the CSS war

JSS usage

56

Page 57: PreJSS: the final point in the CSS war

Killer feature

Page 58: PreJSS: the final point in the CSS war

58

Critical Path CSS

Styles by JSSPre-processed CSS

1. All styles

2. Selected manually

3. Per CSS file

1. Rendered styles

2. Selected automatically

3. Per Components state

Page 59: PreJSS: the final point in the CSS war
Page 60: PreJSS: the final point in the CSS war

JSS features

60

1. Render styles for Component tree onlyto get Critical CSS

2. Remove styles when Components detached

3. Styles re-calculation “on-the-fly”

4. Portable: DOM, Inline Styles, React Native

5. Great performance

Page 61: PreJSS: the final point in the CSS war

JSS maintenance

61

Page 62: PreJSS: the final point in the CSS war

What’s about bad things?

Page 63: PreJSS: the final point in the CSS war

JSS means

1. You can’t re-use already existing CSS

2. You can’t copy CSS from a wide range of awesome examples

3. You can’t copy CSS from DevTools

Page 64: PreJSS: the final point in the CSS war

Good news

Page 65: PreJSS: the final point in the CSS war

Now you can

Page 66: PreJSS: the final point in the CSS war

PreJSS

Page 67: PreJSS: the final point in the CSS war

Universal CSS to JSS adapter

Page 68: PreJSS: the final point in the CSS war
Page 69: PreJSS: the final point in the CSS war

After PreJSS

Page 70: PreJSS: the final point in the CSS war
Page 71: PreJSS: the final point in the CSS war

Template Strings + PostCSS +

JSS + ❤ = PreJSS

Page 72: PreJSS: the final point in the CSS war

Problems before

72

1. Wide range of CSS frameworks

2. A lot of CSS formats

3. A few of CSS parsers

4. A dozens of JSS formats

5. Hard to migrate from CSS to JSS

Page 73: PreJSS: the final point in the CSS war

PreJSS Architecture

1. Styles Declaration

2. CSS Parser *

3. PreJSS Adapter *

Styles Declarations

PreJSS Adapter

Any CSS-in-JS

library

Prepare CSS

CSS Parser

Prepare JSS

* - optional, overridable, PostCSS as default

(built-in)

73

Page 74: PreJSS: the final point in the CSS war

74

1. Use already existing CSS

2. Use CSS from a wide range of awesome examples

3. Use CSS from DevTools

PreJSS means

Page 75: PreJSS: the final point in the CSS war

Syntax Highlighting Concept

Page 76: PreJSS: the final point in the CSS war

PreJSS ecosystem

76

1. Loader for webpack to use CSS styles as JSS

2. Babel plugin to transform PreJSS Styles Declarations into JSS objects

3. Styles Linter by PostCSS plugin

4. Syntax highlighting (WIP)

5. CLI tool for converting CSS into JS modules

Page 77: PreJSS: the final point in the CSS war

PreJSS in real world

77

Page 78: PreJSS: the final point in the CSS war

78

PreJSS

JSS

CSS

1. No CSS wars anymore

2. Vendor-less

3. Use the best bits ofwhole CSS world

4. Less complexity

5. Saved time and budget

6. Focus on important things

PreJSS is the final point

Page 79: PreJSS: the final point in the CSS war

79

100th star today 🎉

Page 80: PreJSS: the final point in the CSS war

https://twitter.com/denisizmaylov/status/736321066403045376

80

Page 81: PreJSS: the final point in the CSS war

Welcome to the club

Page 82: PreJSS: the final point in the CSS war

https://github.com/axept/prejss

82

Page 83: PreJSS: the final point in the CSS war

Questions?

@DenisIzmaylov

DenisIzmaylov

denis_izmaylov

Denis Izmaylov

Send “Hello” to:

[email protected]