https://slides.com/tylergraf/performance-in-react
Senior Web Dev
FamilySearch
tyler@familysearch.org
@tylergraf
(1 MB uncompressed)
(1 MB uncompressed)
http connection
SSL
| Device | Unique visitors in the last year | Perc |
| ------------------------- | -------------------------------- | ----- |
| Apple iPhone | 7,841,169 | 25.2% |
| Apple iPad | 3,280,247 | 10.6% |
| Samsung Galaxy S8 | 684,974 | 2.2% |
| Samsung Galaxy S9 | 521,036 | 1.7% |
| Samsung Galaxy Note 8 | 428,127 | 1.4% |
| Samsung Galaxy S9 Plus | 420,489 | 1.4% |
| Verizon Galaxy S7 | 345,610 | 1.1% |
| Samsung Galaxy S8 Plus | 334,761 | 1.1% |
| Samsung Galaxy Tab A 10.1 | 235,683 | 0.8% |
| Samsung Galaxy Note 9 | 214,554 | 0.7% |
| Motorola Moto G5 Plus | 206,180 | 0.7% |
| Google Pixel 2 | 182,505 | 0.6% |
| Google Pixel 2 XL | 152,412 | 0.5% |
| Samsung Galaxy S8 | 143,763 | 0.5% |
| Samsung Galaxy S7 | 134,330 | 0.4% |
| Samsung Galaxy S7 Edge | 134,220 | 0.4% |
| Unknown M3 | 133,875 | 0.4% |
| Motorola Moto G6 | 125,804 | 0.4% |
| AT&T Galaxy S7 | 121,423 | 0.4% |
| Motorola Moto G4 | 121,030 | 0.4% |
| Motorola Moto E4 | 118,282 | 0.4% |
| Amazon Fire HD 10 | 116,831 | 0.4% |
| Samsung Galaxy J7 Prime | 116,220 | 0.4% |
| Amazon Fire HD 8 | 110,212 | 0.4% |
| Verizon Galaxy S6 | 109,875 | 0.4% |
| Verizon Galaxy S7 edge | 107,282 | 0.3% |
| Samsung Galaxy Tab 4 10.1 | 104,458 | 0.3% |
| Samsung Galaxy Tab S2 | 102,892 | 0.3% |
| T-Mobile Galaxy S7 | 102,262 | 0.3% |
| Samsung Galaxy J2 Prime | 101,905 | 0.3% |
| Samsung Galaxy A5 | 100,792 | 0.3% |
| Samsung Galaxy J5 Prime | 98,201 | 0.3% |
(after visiting the home page)
(Cached View)
import React, { Suspense, lazy } from "react";
import { Switch, Route, Router, NotFound } from "@fs/zion-router";
const PageOne = lazy(() => import("./components/pages/PageOne"));
const PageTwo = lazy(() => import("./components/pages/PageTwo"));
const PageThree = lazy(() => import("./components/pages/PageThree"));
export default function App() {
return (
<Suspense>
<Router>
<Switch>
<Route exact path="/" component={PageOne} />
<Route exact path="/two" component={PageTwo} />
<Route exact path="/three" component={PageThree} />
<Route component={NotFound} />
</Switch>
</Router>
</Suspense>
);
}
import React, { useState, Suspense, lazy } from "react";
import Person from "../components/Person";
import { Button } from "@fs/zion-ui";
const OverLay = lazy(() => import("../components/OverLay"));
export default function PageOne() {
const [showMore, setShowMore] = useState();
return (
<Suspense fallback={<div>Loading...</div>}>
<Person />
<Button type="button" onClick={() => setShowMore(true)}>
Show me more!
</Button>
{showMore && <OverLay />}
</Suspense>
);
}
Way below the fold
SHOW MORE
Showing more
.icon.thing {
background:
url(data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7)
no-repeat
left center;
padding: 5px 0 5px 25px;
}
.icon.thing2 {
background:
url(data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7)
no-repeat
left center;
padding: 5px 0 5px 25px;
}
.icon.thing3 {
background:
url(data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7)
no-repeat
left center;
padding: 5px 0 5px 25px;
}
.icon.thing4 {
background:
url(data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7)
no-repeat
left center;
padding: 5px 0 5px 25px;
}
data:image * 100
// maths.js
export function add(x,y) {
return x + y
}
export function subtract(x,y) {
return x - y
}
// main.js
import { add } from './maths';
add(10, 5)
Subtract won't be included in the bundle
Doesn't work with commonjs modules.
// maths.js
exports.add = (x,y) => {
return x + y
}
exports.subtract = (x,y) => {
return x - y
}
// main.js
import { add } from './maths';
add(10, 5)
Look at package.json main and module
{
"name": "cool-package",
"main": "./dist/main.js",
"module": "./dist/main.es6.js"
}
Webpack will look for module first, then main.
export function doStuff(){
// do stuff
}
main.js, may use es6 modules as well, look at the source code.
Along with a bunch of other info like gzipped size, it includes tree-shakability.
Be aware of packages and versions
vs
Real User Monitoring
setCookie https://www.familysearch.org fssessionid=82cc969a-787e-ca9f-8a06-b6093a54787f-prod
navigate https://www.familysearch.org/tree/pedigree/landscape/LBGY-WZG
navigate https://www.familysearch.org
setCookie https://www.familysearch.org fssessionid=82cc969a-787e-ca9f-8a06-b6093a54787f-prod
navigate https://www.familysearch.org/tree/pedigree/landscape/LBGY-WZG
Homepage => Person Page
Person Page
Senior Web Dev
FamilySearch
tyler@familysearch.org
@tylergraf
https://slides.com/tylergraf/performance-in-react