SlideShare a Scribd company logo
Open data for good
Lessons, experiences and pains
of a hobby project using React
Marco Liberati
@dej611
Work for:
Agenda
● Getting started with React: picking the right boilerplate
● The goal: the original idea
● The monster: what it became
● Libraries and tools: what and how to choose it
● Everything is ready
● Everything is ready: performance time
● Lessons
● What’s next?
Getting started with React
● Project idea started initially in early 2017
● create-react-app vs next.js vs boilerplate
● Redux had to be there
● Some experience with setting up webpack, babel, etc… manually
https://youtu.be/eb60pnjABGg?t=16
Setting up webpack, babel, etc… manually
The goal
● Simple dashboard as a way to learn React and d3 together
● Few charts and and a map, all interactive
● Use Redux to coordinate the dashboard
The monster: what it became
● Multi language visual article (charts too)
● 3 maps (~10000 SVG elements)
● 18 charts
● Autocomplete with all Italian towns
● Redux everywhere
● Lazy loading e pre-rendering
● Obsessive performance profiling
Libraries and tools
● CSS Framework: Bulma - CSS only, no JS. Easy to use it with React
● React + D3: vx - a lot of cool examples. I thought it was a good choice until...
Heavily based on HOC...
...with almost no
documentation…
...and you need some d3
prior experience to fully
understand the examples.
Libraries and tools
● CSS Framework: Bulma - CSS only, no JS. Easy to use it with React
● React + D3: vx - a lot of cool examples. I thought it was a good choice until...
● Maps: react-simple-maps - few examples but lean. Very elegant code in the demo.
Libraries and tools
● CSS Framework: Bulma - CSS only, no JS. Easy to use it with React
● React + D3: vx - a lot of cool examples. I thought it was a good choice until...
● Maps: react-simple-maps - few examples but lean. Very elegant code in the demo.
● Hosting: now.sh - A single command to deploy. Free.
● I18n: react-i18next - I knew it when introduced it at the end.
● Prerendering: puppeteer - a bit over engineered but easy to use.
First “ready” version
● Sort of spaghetti code
● Redux everywhere
● Everything in the bundle
○ JSON
○ shapefiles
● Load everything at bootstrap
● No preview for social network
● No responsive charts
● Only in Italian
~ May 2019
First “ready” version: performance time
● Make the article usable in mobile
● Shrink the bundle size
● Metrics to track:
○ First Contentful Paint
○ Time to interactive
First “ready” version: performance time
● Make the article usable in mobile
○ Reducing DOM size: prerendering maps? Think about interaction impacts.
○ Minimize main-thread work: prerendering maps?
○ Reduce Javascript execution time: prerendering maps!
● Shrinking the bundle size:
● Metrics to track:
○ First Contentful Paint
○ Time to interactive
Before After (prerendering)
Prerender
First “ready” version: performance time
● Make the article usable in mobile
○ Reducing DOM size: prerendering maps? Think about interaction impacts.
○ Minimize main-thread work: prerendering maps?
○ Reduce Javascript execution time: prerendering maps!
● Shrinking the bundle size:
○ Avoid enormous network payload:
■ GeoJSON => TopoJSON ~ -14 MB
■ lazy loading maps shapes
● Metrics to track:
○ First Contentful Paint
○ Time to interactive
Before (prerendering) After (+ lazy loading)
First “ready” version: performance time
● What about desktop
version?
Prerendering is for mobile
only. I want desktop to
leverage all the interactivity,
but it loads everything on
bootstrap...
First “ready” version: performance time
● What about desktop version?
IntersectionObserver to the rescue!
https://github.com/researchgate/react-intersection-observer
Credit: Mozilla Hacks
Before After (+ IntersectionObserver)
Lessons
● The React ecosystem is huge and it’s easy to get lost in it
● create-react-app it’s the best prototype tool
○ Recently updated from CRA 1.x to CRA 3.x with a single code line changed!
● Before choosing a library, open the examples code, copy and paste in your
codebase and see if it works!
○ vx had cool examples but hard to adapt to my case without a deep knowledge of d3
● End your prototype/project (feature-complete) and then revisit (performance,
styling, etc…)
● CSS framework only: Bulma
● Performance profiling iterative: measure, change and measure again
What’s next?
● Swap create-react-app with Gatsby
○ SSR = better performance (especially in mobile)
○ Find other ways to shrink the bundle size
● Use selectors
○ Interactions with SVG may have a high cost and often it means to heavily change the DOM
○ Many changes can be skipped with selectors
● Preact
○ does it work with Gatsby?
● Test
○ What to test?
○ There’s no critical path here
Have an idea? Want to contribute?
https://github.com/dej611/abusi-edilizi-opendata
Open data for good
Marco Liberati
@dej611
● Create-react-app: https://facebook.github.io/create-react-app/docs/getting-started
● Lighthouse: https://developers.google.com/web/tools/lighthouse/
● vx: https://vx-demo.now.sh/
● react-simple-maps: https://www.react-simple-maps.io/
● IntersectionObserver: https://github.com/researchgate/react-intersection-observer
● GeoJSON => TopoJSON: https://github.com/topojson/topojson-server
● I18n: https://github.com/i18next/react-i18next
● Bulma: https://bulma.io/
● Next.js: https://nextjs.org/
● Now.sh: https://zeit.co/now
● Don’t build that app! : https://www.youtube.com/watch?v=mVjZQrsXBQE
References and links:

More Related Content

What's hot (19)

ODP
Hot Reloading with React - Experiences
Heribert Schütz
 
PDF
Super lazy side projects - Hamik Mukelyan
Drew Malone
 
PDF
Code-Hub
Curran Kelleher
 
PDF
Influx/Days 2017 San Francisco | Dan Vanderkam
InfluxData
 
PDF
The Future is Here: ECMAScript 6 in the Wild
Adrian-Tudor Panescu
 
PPTX
Réaliser un jeu cross plateformes avec WebGL et babylon.js
davrous
 
PDF
You Don't Know WebGL at GREE Tech Talk #08
Guangyao Liu
 
PDF
Code:Nation Tech Stack
Elton Minetto
 
ODP
Avoiding common pitfalls of datetime from a webapp's perspective
indradhanush92
 
PDF
Eclipse Democamp Nantes 2017 - Back to the Future: EclipseConverge & Devoxx US
melbats
 
PDF
Android build process (1)
Shubham Goyal
 
PDF
Aws uk ug #8 not everything that happens in vegas stay in vegas
Peter Mounce
 
PPTX
Introduction to React
Quentin Leonetti
 
PDF
Constinuous Integration
Gabriel Araujo
 
PDF
three.js WebGL library presentation
Yleisradio
 
PDF
Minko - Windows App Meetup Nov. 2013
Minko3D
 
PPTX
How volkswagen used microservices and automation to develop self service solu...
Marcos Entenza Garcia
 
PDF
Introducing Electron
Baylee Schmeisser
 
PPTX
Golang
Michael Blake
 
Hot Reloading with React - Experiences
Heribert Schütz
 
Super lazy side projects - Hamik Mukelyan
Drew Malone
 
Code-Hub
Curran Kelleher
 
Influx/Days 2017 San Francisco | Dan Vanderkam
InfluxData
 
The Future is Here: ECMAScript 6 in the Wild
Adrian-Tudor Panescu
 
Réaliser un jeu cross plateformes avec WebGL et babylon.js
davrous
 
You Don't Know WebGL at GREE Tech Talk #08
Guangyao Liu
 
Code:Nation Tech Stack
Elton Minetto
 
Avoiding common pitfalls of datetime from a webapp's perspective
indradhanush92
 
Eclipse Democamp Nantes 2017 - Back to the Future: EclipseConverge & Devoxx US
melbats
 
Android build process (1)
Shubham Goyal
 
Aws uk ug #8 not everything that happens in vegas stay in vegas
Peter Mounce
 
Introduction to React
Quentin Leonetti
 
Constinuous Integration
Gabriel Araujo
 
three.js WebGL library presentation
Yleisradio
 
Minko - Windows App Meetup Nov. 2013
Minko3D
 
How volkswagen used microservices and automation to develop self service solu...
Marcos Entenza Garcia
 
Introducing Electron
Baylee Schmeisser
 

Similar to Open data for good (20)

PDF
React for non techies
Amy Crimmens
 
PDF
React for non techies
React London Community
 
PDF
React for Non Techies
Jack Hoy
 
PPTX
Introduction to React Native
Waqqas Jabbar
 
PPTX
Hack Rio/OS
Kishore Neelamegam
 
PDF
Who needs containers in a serverless world
Matthias Luebken
 
PPTX
From React to React Native - Things I wish I knew when I started
sparkfabrik
 
PDF
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Ron Munitz
 
PPTX
Introduction to react native @ TIC NUST
Waqqas Jabbar
 
PPTX
From Ant to Rake
jazzman1980
 
PDF
Castle Game Engine and the joy of making and using a custom game engine
Michalis Kamburelis
 
PDF
Rebuilding Reddit, A Case Study - Chris Slowe, CTO, Reddit
Traction Conf
 
PDF
Build a real app with react native
John Pham
 
PDF
An Introduction to ReactNative
Michał Taberski
 
PDF
The Self-Service Developer - GOTOCon CPH
Laszlo Fogas
 
PDF
Create ReactJS Component & publish as npm package
Andrii Lundiak
 
PPTX
React Conf, Dhaka 2018 - Understanding React: The React Way of Doing Things b...
Tamal Chowdhury
 
DOCX
Gaganjot Kaur- The Nx Workspace.docx
Gaganjot kaur
 
PPTX
20180518 QNAP Seminar - Introduction to React Native
Eric Deng
 
PDF
React Conf 17 Recap
Alex Babkov
 
React for non techies
Amy Crimmens
 
React for non techies
React London Community
 
React for Non Techies
Jack Hoy
 
Introduction to React Native
Waqqas Jabbar
 
Hack Rio/OS
Kishore Neelamegam
 
Who needs containers in a serverless world
Matthias Luebken
 
From React to React Native - Things I wish I knew when I started
sparkfabrik
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Ron Munitz
 
Introduction to react native @ TIC NUST
Waqqas Jabbar
 
From Ant to Rake
jazzman1980
 
Castle Game Engine and the joy of making and using a custom game engine
Michalis Kamburelis
 
Rebuilding Reddit, A Case Study - Chris Slowe, CTO, Reddit
Traction Conf
 
Build a real app with react native
John Pham
 
An Introduction to ReactNative
Michał Taberski
 
The Self-Service Developer - GOTOCon CPH
Laszlo Fogas
 
Create ReactJS Component & publish as npm package
Andrii Lundiak
 
React Conf, Dhaka 2018 - Understanding React: The React Way of Doing Things b...
Tamal Chowdhury
 
Gaganjot Kaur- The Nx Workspace.docx
Gaganjot kaur
 
20180518 QNAP Seminar - Introduction to React Native
Eric Deng
 
React Conf 17 Recap
Alex Babkov
 
Ad

Recently uploaded (20)

PDF
B M Mostofa Kamal Al-Azad [Document & Localization Expert]
Mostofa Kamal Al-Azad
 
PPTX
My Mother At 66! (2).pptx00000000000000000000000000000
vedapattisiddharth
 
PDF
I Want to join occult brotherhood for money ritual#((+2347089754903))
haragonoccult
 
PDF
Transmission Control Protocol (TCP) and Starlink
APNIC
 
PDF
ContextForge MCP Gateway - the missing proxy for AI Agents and Tools
Mihai Criveti
 
PPT
Almos Entirely Correct Mixing with Apps to Voting
gapati2964
 
PDF
Download Google Chrome for Fast and Secure Web Browsing Experience
hgfdsqetuiplmnvcz43
 
PDF
BroadLink Cloud Service introduction.pdf
DevendraDwivdi1
 
PPTX
原版一样(ISM毕业证书)德国多特蒙德国际管理学院毕业证多少钱
taqyed
 
PDF
03 Internal Analysis Strategik Manajemen.pdf
AhmadRifaldhi
 
PDF
Clive Dickens RedTech Public Copy - Collaborate or Die
Clive Dickens
 
PPTX
原版一样(ANU毕业证书)澳洲澳大利亚国立大学毕业证在线购买
Taqyea
 
PDF
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
PDF
Materi tentang From Digital Economy to Fintech.pdf
Abdul Hakim
 
PDF
Slides: Eco Economic Epochs for The World Game (s) pdf
Steven McGee
 
PPTX
BitRecover OST to PST Converter Software
antoniogosling01
 
PDF
Google Chrome vs Other Browsers: Why Users Still Prefer It.pdf
hgfdsqetuiplmnvcz43
 
PDF
What Is Google Chrome? Fast & Secure Web Browser Guide
hgfdsqetuiplmnvcz43
 
PPTX
Q1 English3 Week5 [email protected]
JenniferCawaling1
 
PPTX
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
B M Mostofa Kamal Al-Azad [Document & Localization Expert]
Mostofa Kamal Al-Azad
 
My Mother At 66! (2).pptx00000000000000000000000000000
vedapattisiddharth
 
I Want to join occult brotherhood for money ritual#((+2347089754903))
haragonoccult
 
Transmission Control Protocol (TCP) and Starlink
APNIC
 
ContextForge MCP Gateway - the missing proxy for AI Agents and Tools
Mihai Criveti
 
Almos Entirely Correct Mixing with Apps to Voting
gapati2964
 
Download Google Chrome for Fast and Secure Web Browsing Experience
hgfdsqetuiplmnvcz43
 
BroadLink Cloud Service introduction.pdf
DevendraDwivdi1
 
原版一样(ISM毕业证书)德国多特蒙德国际管理学院毕业证多少钱
taqyed
 
03 Internal Analysis Strategik Manajemen.pdf
AhmadRifaldhi
 
Clive Dickens RedTech Public Copy - Collaborate or Die
Clive Dickens
 
原版一样(ANU毕业证书)澳洲澳大利亚国立大学毕业证在线购买
Taqyea
 
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
Materi tentang From Digital Economy to Fintech.pdf
Abdul Hakim
 
Slides: Eco Economic Epochs for The World Game (s) pdf
Steven McGee
 
BitRecover OST to PST Converter Software
antoniogosling01
 
Google Chrome vs Other Browsers: Why Users Still Prefer It.pdf
hgfdsqetuiplmnvcz43
 
What Is Google Chrome? Fast & Secure Web Browser Guide
hgfdsqetuiplmnvcz43
 
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
Ad

Open data for good

  • 1. Open data for good Lessons, experiences and pains of a hobby project using React
  • 3. Agenda ● Getting started with React: picking the right boilerplate ● The goal: the original idea ● The monster: what it became ● Libraries and tools: what and how to choose it ● Everything is ready ● Everything is ready: performance time ● Lessons ● What’s next?
  • 4. Getting started with React ● Project idea started initially in early 2017 ● create-react-app vs next.js vs boilerplate ● Redux had to be there ● Some experience with setting up webpack, babel, etc… manually
  • 6. The goal ● Simple dashboard as a way to learn React and d3 together ● Few charts and and a map, all interactive ● Use Redux to coordinate the dashboard
  • 7. The monster: what it became ● Multi language visual article (charts too) ● 3 maps (~10000 SVG elements) ● 18 charts ● Autocomplete with all Italian towns ● Redux everywhere ● Lazy loading e pre-rendering ● Obsessive performance profiling
  • 8. Libraries and tools ● CSS Framework: Bulma - CSS only, no JS. Easy to use it with React ● React + D3: vx - a lot of cool examples. I thought it was a good choice until... Heavily based on HOC... ...with almost no documentation… ...and you need some d3 prior experience to fully understand the examples.
  • 9. Libraries and tools ● CSS Framework: Bulma - CSS only, no JS. Easy to use it with React ● React + D3: vx - a lot of cool examples. I thought it was a good choice until... ● Maps: react-simple-maps - few examples but lean. Very elegant code in the demo.
  • 10. Libraries and tools ● CSS Framework: Bulma - CSS only, no JS. Easy to use it with React ● React + D3: vx - a lot of cool examples. I thought it was a good choice until... ● Maps: react-simple-maps - few examples but lean. Very elegant code in the demo. ● Hosting: now.sh - A single command to deploy. Free. ● I18n: react-i18next - I knew it when introduced it at the end. ● Prerendering: puppeteer - a bit over engineered but easy to use.
  • 11. First “ready” version ● Sort of spaghetti code ● Redux everywhere ● Everything in the bundle ○ JSON ○ shapefiles ● Load everything at bootstrap ● No preview for social network ● No responsive charts ● Only in Italian ~ May 2019
  • 12. First “ready” version: performance time ● Make the article usable in mobile ● Shrink the bundle size ● Metrics to track: ○ First Contentful Paint ○ Time to interactive
  • 13. First “ready” version: performance time ● Make the article usable in mobile ○ Reducing DOM size: prerendering maps? Think about interaction impacts. ○ Minimize main-thread work: prerendering maps? ○ Reduce Javascript execution time: prerendering maps! ● Shrinking the bundle size: ● Metrics to track: ○ First Contentful Paint ○ Time to interactive
  • 16. First “ready” version: performance time ● Make the article usable in mobile ○ Reducing DOM size: prerendering maps? Think about interaction impacts. ○ Minimize main-thread work: prerendering maps? ○ Reduce Javascript execution time: prerendering maps! ● Shrinking the bundle size: ○ Avoid enormous network payload: ■ GeoJSON => TopoJSON ~ -14 MB ■ lazy loading maps shapes ● Metrics to track: ○ First Contentful Paint ○ Time to interactive
  • 17. Before (prerendering) After (+ lazy loading)
  • 18. First “ready” version: performance time ● What about desktop version? Prerendering is for mobile only. I want desktop to leverage all the interactivity, but it loads everything on bootstrap...
  • 19. First “ready” version: performance time ● What about desktop version? IntersectionObserver to the rescue! https://github.com/researchgate/react-intersection-observer Credit: Mozilla Hacks
  • 20. Before After (+ IntersectionObserver)
  • 21. Lessons ● The React ecosystem is huge and it’s easy to get lost in it ● create-react-app it’s the best prototype tool ○ Recently updated from CRA 1.x to CRA 3.x with a single code line changed! ● Before choosing a library, open the examples code, copy and paste in your codebase and see if it works! ○ vx had cool examples but hard to adapt to my case without a deep knowledge of d3 ● End your prototype/project (feature-complete) and then revisit (performance, styling, etc…) ● CSS framework only: Bulma ● Performance profiling iterative: measure, change and measure again
  • 22. What’s next? ● Swap create-react-app with Gatsby ○ SSR = better performance (especially in mobile) ○ Find other ways to shrink the bundle size ● Use selectors ○ Interactions with SVG may have a high cost and often it means to heavily change the DOM ○ Many changes can be skipped with selectors ● Preact ○ does it work with Gatsby? ● Test ○ What to test? ○ There’s no critical path here
  • 23. Have an idea? Want to contribute? https://github.com/dej611/abusi-edilizi-opendata
  • 24. Open data for good Marco Liberati @dej611
  • 25. ● Create-react-app: https://facebook.github.io/create-react-app/docs/getting-started ● Lighthouse: https://developers.google.com/web/tools/lighthouse/ ● vx: https://vx-demo.now.sh/ ● react-simple-maps: https://www.react-simple-maps.io/ ● IntersectionObserver: https://github.com/researchgate/react-intersection-observer ● GeoJSON => TopoJSON: https://github.com/topojson/topojson-server ● I18n: https://github.com/i18next/react-i18next ● Bulma: https://bulma.io/ ● Next.js: https://nextjs.org/ ● Now.sh: https://zeit.co/now ● Don’t build that app! : https://www.youtube.com/watch?v=mVjZQrsXBQE References and links: