Weitere ähnliche Inhalte
Ähnlich wie Building high-performance web applications with Preact (20)
Mehr von Maurice De Beijer [MVP] (20)
Kürzlich hochgeladen (20)
Building high-performance web applications with Preact
- 3. Maurice de Beijer
The Problem Solver
MicrosoftAzure MVP
Freelance developer/instructor
Twitter: @mauricedb, @NG_Tutorial and @React_Tutorial
Web: http://www.TheProblemSolver.nl
E-mail: maurice.de.beijer@gmail.com
3
- 4. Try it https://bit.ly/dnz-preact
© ABL - The Problem Solver 4
- 6. Why
performance?
40% of the website traffic is from mobile devices.
Bol.com in July 2016
Adding 100 ms of latency costs 1% of sales.
Amazon.com
© ABL - The Problem Solver 6
- 9. “Performance is the art of
avoiding work, and
making any work you do
as efficient as possible”
-- Paul Lewis --
© ABL - The Problem Solver 9
- 17. A Preact
component
import { h, render, Component } from 'preact’; // <= h() replaces React.createElement()
class Clock extends Component { // <= Always ES2015 classes
constructor() {
super();
this.state.now = new Date();
}
componentDidMount() {
this.timer = setInterval(() => this.setState({ now: new Date() }), 1000);
}
componentWillUnmount() {
clearInterval(this.timer);
}
render({}, {now}) { // <= props and state passed
return <span>{ now.toLocaleTimeString() }</span>;
}
}
render(<Clock />, document.body); // <= render() instead of ReactDOM.render()
© ABL - The Problem Solver 17
- 19. What is
missing?
PropType validation.
Part of preact-compat
React.Children.
Part of preact-compat
Synthetic Events.
Preact only targets the Browser
Context is simplified.
© ABL - The Problem Solver 19
- 20. “It's easier to make a
fast app than to speed
up a slow app”
-- Me --
© ABL - The Problem Solver 20
- 21. ECMAScript
imports
import _ from 'lodash';
_.forEach(data, e => console.log(e));
© ABL - The Problem Solver 21
import { forEach } from 'lodash/forEach';
forEach(data, e => console.log(e));
- 24. PRPL
Push critical resources for the initial URL route.
Render initial route.
Pre-cache remaining routes.
Lazy-load and create remaining routes on demand.
© ABL - The Problem Solver 24
- 37. Conclusion
Everyone loves faster web apps.
And they are good for business
Do as few request as possible to display the first page.
The fastest HTTP request is one not made
Use the PRPL pattern
Preact is small and fast.
The CLI gives you most of the PRPL pattern out of the box
© ABL - The Problem Solver 37
Hinweis der Redaktion
- https://pixabay.com/nl/supersonische-vechter-vliegtuigen-63211/
- https://pixabay.com/nl/boord-blackboard-lettertype-1805318/
- https://www.pexels.com/photo/train-on-railroad-tracks-against-sky-258367/
- https://unsplash.com/photos/EXcDH29WLbg
- https://pixabay.com/nl/dolfijn-kind-kinderen-spelen-1548448/
- https://pixabay.com/nl/marokko-truck-vrachtwagen-hooi-842660/
- https://pixabay.com/nl/draaien-loper-lange-afstand-fitness-573762/
- https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
- https://pixabay.com/en/technology-servers-server-1587673/
- https://pixabay.com/nl/tools-hamer-nagel-nagels-boor-15539/
- https://jonassebastianohlsson.com/criticalpathcssgenerator/
- https://pixabay.com/nl/systeem-netwerk-nieuws-persoonlijke-2546093/
- https://unsplash.com/search/splitting?photo=Xxd33FUBQeA
- https://pixabay.com/nl/sprinkhaan-viridissima-groene-193721