SlideShare a Scribd company logo
1 of 67
Frontend Monolithen: 

Rette sich wer kann!
In 2016 the average webpage size passed the size of Doom
https://mobiforge.com/research-analysis/the-web-is-doom
Web-Page Obesity
The first Mac had
128k of RAM in 1984.
Web: Size does Matter!
The Cost of JavaScript
optional ajax request
data
http://thedomain:80/app
http://thedomain:80/api/data/first
http://thedomain:80/app#/first
http://thedomain:80/app#/second
"navigate" to "first"
screen
http://thedomain:80/app#/first
navigation
Browser Serverinitial request
html-shell
assets
load data &
render screen with JS
"navigate" to
"second" screen
load data &
render screen with JS
html-shell is loaded
optional ajax request
http://thedomain:80/api/data/second
data
loading...
appbootstrapping
Network
CostCPU Cost
The Cost of JavaScript
https://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d4
For mobile, aim for a JS budget of < 170KB minified/compressed.
Server Side Rendering
http://thedomain:80/app
http://thedomain:80/app#/first
Browser Serverinitial request
html-shell
assets
html-shell 

is displayedloading...
Angular renders 

the page
run JS
http://thedomain:80/app/first
http://thedomain:80/app/first
Browser Serverinitial request
html-shell

with content
assets
rendered
page is
displayed
Angular is
bootstrapped 

on the page
run JS
Angular
renders 

the page
run JS
Traditional SPA:
Enabling Server Side Rendering:
https://angular.io/guide/router#appendix-locationstrategy-and-browser-url-styles
Time to Paint vs.Time to Interactive
https://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d4
DEMO:
https://www.lei.admin.ch/
Speed == Money
https://www.thinkwithgoogle.com/feature/mobile/
Amazon did tests that showed they would lose $1.6
BILLION every year if they slowed down by just one second.
Walmart Study: For every 100 ms of improvement, they grew
incremental revenue by up to 1%.
https://www.fastcompany.com/1825005/how-one-second-could-cost-amazon-16-billion-sales
https://blog.radware.com/applicationdelivery/wpo/2014/04/web-page-speed-affect-conversions-infographic/
Enterprise Applications
History of Enterprise Apps
• Rich Clients accessing the DB
• Server-Side Web with multiple Domains
• Moving to SPA -> enables Microservices
• Eclipse RCP "Workbenches" -> Moving
to Web
The Fat Client
Feature 1 Feature 2 Feature 2
Rich Client
Workbench & Monolith
Feature 1 Feature 2 Feature 2
Workbench
Monolithic Server
Feature 1 Feature 2 Feature 3
Traditional Web Monolith
Feature 1 Feature 2 Feature 3
Frontend
Browser
Monolithic Server
SPA Monolith
Feature 1 Feature 2 Feature 3
Frontend
Monolithic Server
SPA Monolith & Microservices
Feature 1 Feature 2 Feature 3
Frontend
API API API
Composition &
Orchestration
happens in the
Client
Rich Client Migrations: 

The Rise of the Monoliths
API
Workbench
Monolithic Server
Feature 1 Feature 2 Feature 3
Feature 1 Feature 2 Feature 3
Feature 1
API
Feature 1
API
Feature 1
SPA Monolith
App
API
Workbench
Monolithic Server
Feature 1 Feature 2 Feature 3
Feature 1 Feature 2 Feature 3
Feature 1
API
Feature 1
API
Feature 1
SPA Monolith
App
Improvement!
Much Worse!
Beware of the Monolith
Unfortunately, we've seen many teams create front-end
monoliths - a single, large and sprawling browser
application - on top of their back-end services.
-ThoughtWorksTechnology Radar
App1 App2 App3
API 1 API 2 API 3
SPA Monolith
Problems of the Frontend Monolith
• Performance 

-> size is still relevant for web applications!
• Coupling & Dependencies
• preventing change / agility / time to market
• preventing effective/simple organization

(effective end-to-end delivery, self organizing teams ...)
Coupling / Lock-Step Releases
"Think about the granularity of development & deployment artifacts"
Application 1
- implemented by team 1
- driven by org-unit 1
Application 2
- implemented by team 2
- driven by org-unit 2
shared lib
- inhouse lib
- 3rd party lib 

(ie. Angular, React)
team 2 needs
to change or
update the lib
team 1 is
immediately
affected
The consequence is coupling between App1 and App 2:
- teams have to coordinate changes to the shared lib.
- development & release schedules of applications are coupled
Who is responsible for
testing/fixing application 1?
release
release
release
release
release
release
Problems of the Frontend Monolith
• The web is traditionally not made for
complex applications
• global scope / no isolation / no modularization concepts
• extremely dynamic (typing, monkey paching ...)
• browser differences
• Frequent technology changes
• core technologies are very backwards compatible
• ecosystem moves at break-neck speed
The Bad Parts
http://www.commitstrip.com/en/2018/01/08/new-year-new-frameworks/
The first rule of huge 

enterprise applications is: 

You do not build huge enterprise
applications.
The second rule of huge
enterprise applications is:
You do not build huge
enterprise applications.
How?
Micro Frontends:
An architectural style where
independently deliverable frontend
applications are composed into a
greater whole.
?
Micro Frontends
App 1 App 2 App 3
App
API 1 API 2 API 3
SPA Monolith
API 1 API 2 API 3
? ?
The million dollar question:

Modularizing frontend applications.
https://micro-frontends.org/
The Link
<a	href="..."	>
The magical integration pattern that the web is built upon:
Microfrontend Flavors: Mini SPAs
Feature 1 Feature 2 Feature 3
App 1
API API API
App 2 App 3
Page Page PageLink Link
You have complete isolation. But jumping between apps is a full page load!
DEMO
Mini SPAs
Challenges
• Performance: Starting the Mini-SPAs has to be very quick!
• Sharing layout & styles for common UX

-> use reusable technologies for styling -> plain CSS, SASS, less ...

-> be careful with "framework-specific" styling
• Sharing state / context

-> query parameters, cookies, http-headers

-> server side session / context

-> Local Storage / Indexed DB
Feature 1
App 1
Page Link
App2
Page
Feature 1
Context
Remember: Size does Matter
Frameworks could matter ...
Transfer size (KB) for the same application 
https://medium.freecodecamp.org/a-real-world-comparison-of-front-end-frameworks-with-benchmarks-2018-update-e5760fb4a962
Keep an eye on your bundles!
source-map-explorer:

https://www.npmjs.com/package/source-map-explorer
webpack-bundle-analyzer:

https://github.com/webpack-contrib/webpack-bundle-analyzer
npm	install	-g	source-map-explorer	
ng	build	--prod	--source-map	
source-map-explorer	dist/ng-app/main.XYZ.js
npm	install	-g	webpack-bundle-analyzer
ng	build	--prod	--stats-json	
webpack-bundle-analyzer	dist/ng-app/stats.json
www.bundlephobia.com
But I need a single SPA!
Microfrontend Flavors: Sinlge SPA
Feature 1 Feature 2 Feature 3
App 1
API API API
App 2 App 3
Shell D0M D0M
https://github.com/CanopyTax/single-spa
All applications live
on the same DOM.
App-communication
happens over the
DOM.
You will need a shell
• Top-level routing
• Lazy loading of apps (child SPAs)
• Inter-SPA communication
• Sharing a context
Sinlge SPA: iframes
Feature 1 Feature 2 Feature 3
App 1
API API API
App 2 App 3
Shell
dependencies dependencies dependencies
D0M D0M Analogy: complete
classloader isolation.
Browser can leverage
caching, but for each app
all dependencies have to
be parsed, compiled and
executed.
iframeiframeiframe
Option: "Child SPAs" in iframe
Advantages:
- true isolation
- integration of "non-SPA" applications / sites
Disadvantage:
- No isolation: same global DOM, same
scripting context, same global scope
- Responsive layout is difficult
- Router can't access the URL
- Some 3rd party libraries break, since they
depend on document events
Sinlge SPA: Isolated
Feature 1 Feature 2 Feature 3
App 1
API API API
App 2 App 3
Shell
dependencies dependencies dependencies
D0M D0M
Browser can leverage
caching, but for each app
all dependencies have to
be parsed, compiled and
executed.
Like "complete classloader
isolation", but only if the app
& dependencies don't
pollute the global scope. 

Note:Angular comes with Zone.js,
which heavily pollutes the global
scope!
DEMO: Single-Spa
https://single-spa.js.org/
Option: Shared DOM
empty
empty
Sinlge SPA: Shared Dependencies
Feature 1 Feature 2 Feature 3
App 1
API API API
App 2 App 3
Shell
shared dependencies
D0M D0M
Analogy: shared
classloader
Inter-SPA Communication
https://github.com/jbandi/single-spa-portal-example
globalIncrement()	{	
			this.globals.globalEventDistributor.dispatch(this.actions.increment());	
}
Shell
M
ini
SP
A
1
M
ini
SP
A
2
DEMO: Single-Spa
https://single-spa.js.org/
Thighter Integration
Frontend Composition
Feature 1 Feature 2 Feature 3
App 1
API API API
App 2 App 3
Shell
How?
Web Components
Custom Elements API:
customElements.define('element-details',		class	extends	HTMLElement	{	...	})
WebComponents is a series of browser standards for
creating reusable custom elements:
https://developer.mozilla.org/en-US/docs/Web/Web_Components

https://developer.mozilla.org/en-US/docs/Web/API/Window/customElements
Shadow DOM Encapsulation
HTML
templates
markup that is not initially rendered and can be instantiated.
Custom
elements
JavaScript API to define custom elements that can be used in
html and their behavior
JavaScript
html:
<div>	<element-details></element-details>	<div>	
Browser support:
native: Chrome, Safari
polyfill: Firefox, Edge, IE11
Angular Elements
Angular Elements
https://angular.io/guide/elements
Using Angular components as Web Components.
Angular Elements can transform Angular components into classes that
can be registers as custom elemements:
import	{	createCustomElement	}	from	'@angular/elements';	
import	{	PopupComponent	}	from	'./popup.component';	
const	PopupElement	=	createCustomElement(PopupComponent,	{injector});	
customElements.define('element-details',	PopupElement)
Available in Angular 6
in any html (also from React JSX andVue templates):
<div>	<element-details></element-details>	<div>
Vue CLI Compilation
Vue CLI 3 can wrap a vue component / app
inside a Web Component
https://cli.vuejs.org/guide/build-targets.html#web-component 

https://github.com/vuejs/vue-web-component-wrapper
vue-cli-service	build	--target	wc	--name	my-element	./main.js
Build:
<script	src="path/to/my-element.js"></script>	
...	
<my-element></my-element>
any html:
Wrapping React
import	React	from	'react';	
import	ReactDOM	from	'react-dom';	
import	App	from	'./App';	
class	MyApp	extends	HTMLElement	{	
		connectedCallback()	{	
				const	mountPoint	=	document.createElement('span');	
				this.attachShadow({	mode:	'open'	}).appendChild(mountPoint);	
				const	message	=	this.getAttribute('message');	
				ReactDOM.render(<App	message={message}/>,	mountPoint);	
		}	
}	
customElements.define('my-app',	MyApp);	
<my-app	messsage="Hi	there!"></my-app>
any html:
DEMO
https://github.com/manfredsteyer/Angular_MicroApps_Different_Technologies
https://github.com/manfredsteyer/angular-elements-dashboard
More than ever: Size does Matter!
Size Does Matter!
Feature 1 Feature 2 Feature 3
App 1
API API API
App 2 App 3
Shell
670KB
430KB
932KB
Size Does Matter!
Feature 1 Feature 2 Feature 3
App 1
API API API
App 2 App 3
Shell
30KB
35KB
120KB
Angular
React
Vue
300KB
65KB
80KB
Big & Independent 

vs. 

Small & Coupled
More Challenges
Dataflow & sharing state between components:
Applications do not just consist of simple components.

There is shared state & context

(Angular services, React context, Redux stores ...)
WebComponents just have primitive string properties!
Versioning:There is no versioning of custom elements!
"It feels like imperative DOM programming" (remember jQuery?)
There is no Silver Bullet for 

Frontend Modularization
Fragen?
JavaScript / Angular / React Schulungen
& Coachings,

Project-Setup & Proof-of-Concept:
http://ivorycode.com/#schulung

jonas.bandi@ivorycode.com
https://github.com/jbandi/sbb-dev-day-2018

More Related Content

What's hot

Android Development...Using Web Technologies
Android Development...Using Web TechnologiesAndroid Development...Using Web Technologies
Android Development...Using Web TechnologiesCommonsWare
 
HTML5를 활용한 하이브리드 앱개발하기
HTML5를 활용한 하이브리드 앱개발하기HTML5를 활용한 하이브리드 앱개발하기
HTML5를 활용한 하이브리드 앱개발하기정현 황
 
(2015년 상반기) HTML5 및 Hybrid app 최신 동향
(2015년 상반기) HTML5 및 Hybrid app 최신 동향(2015년 상반기) HTML5 및 Hybrid app 최신 동향
(2015년 상반기) HTML5 및 Hybrid app 최신 동향Wonsuk Lee
 
Dreamweaver CS6, jQuery, PhoneGap, mobile design
Dreamweaver CS6, jQuery, PhoneGap, mobile designDreamweaver CS6, jQuery, PhoneGap, mobile design
Dreamweaver CS6, jQuery, PhoneGap, mobile designDee Sadler
 
10 top web development frameworks (new version 21 11)
10 top web development frameworks (new version 21 11)10 top web development frameworks (new version 21 11)
10 top web development frameworks (new version 21 11)Mandar Majmudar
 
Frontend Development Bootcamp - React [Online & Offline] In Bangla
Frontend Development Bootcamp - React [Online & Offline] In BanglaFrontend Development Bootcamp - React [Online & Offline] In Bangla
Frontend Development Bootcamp - React [Online & Offline] In BanglaStack Learner
 
Difference between ajax and silverlight
Difference between ajax and silverlightDifference between ajax and silverlight
Difference between ajax and silverlightUmar Ali
 
Aeternity Blockchain - Ecosystem & Devtools [2019]
Aeternity Blockchain - Ecosystem & Devtools [2019]Aeternity Blockchain - Ecosystem & Devtools [2019]
Aeternity Blockchain - Ecosystem & Devtools [2019]Przemysław Thomann
 
Building a Next Generation Mobile Browser using Web technologies
Building a Next Generation Mobile Browser using Web technologiesBuilding a Next Generation Mobile Browser using Web technologies
Building a Next Generation Mobile Browser using Web technologiesn_adam_stanley
 
Top Web Development Frameworks Comparison: All You Need To Know
Top Web Development Frameworks Comparison: All You Need To KnowTop Web Development Frameworks Comparison: All You Need To Know
Top Web Development Frameworks Comparison: All You Need To KnowPixel Crayons
 
Angular Rebooted: Components Everywhere
Angular Rebooted: Components EverywhereAngular Rebooted: Components Everywhere
Angular Rebooted: Components EverywhereCarlo Bonamico
 
Building Desktop RIAs with PHP, HTML & Javascript in AIR
Building Desktop RIAs with PHP, HTML & Javascript in AIRBuilding Desktop RIAs with PHP, HTML & Javascript in AIR
Building Desktop RIAs with PHP, HTML & Javascript in AIRfunkatron
 
Single Page Application Best practices
Single Page Application Best practicesSingle Page Application Best practices
Single Page Application Best practicesTarence DSouza
 
React vs. angular a comprehensive guideline for choosing right front-end fr...
React vs. angular   a comprehensive guideline for choosing right front-end fr...React vs. angular   a comprehensive guideline for choosing right front-end fr...
React vs. angular a comprehensive guideline for choosing right front-end fr...Katy Slemon
 
Sencha touchonbb10 bootcamp
Sencha touchonbb10 bootcampSencha touchonbb10 bootcamp
Sencha touchonbb10 bootcampn_adam_stanley
 

What's hot (19)

Android Development...Using Web Technologies
Android Development...Using Web TechnologiesAndroid Development...Using Web Technologies
Android Development...Using Web Technologies
 
HTML5를 활용한 하이브리드 앱개발하기
HTML5를 활용한 하이브리드 앱개발하기HTML5를 활용한 하이브리드 앱개발하기
HTML5를 활용한 하이브리드 앱개발하기
 
(2015년 상반기) HTML5 및 Hybrid app 최신 동향
(2015년 상반기) HTML5 및 Hybrid app 최신 동향(2015년 상반기) HTML5 및 Hybrid app 최신 동향
(2015년 상반기) HTML5 및 Hybrid app 최신 동향
 
Dreamweaver CS6, jQuery, PhoneGap, mobile design
Dreamweaver CS6, jQuery, PhoneGap, mobile designDreamweaver CS6, jQuery, PhoneGap, mobile design
Dreamweaver CS6, jQuery, PhoneGap, mobile design
 
10 top web development frameworks (new version 21 11)
10 top web development frameworks (new version 21 11)10 top web development frameworks (new version 21 11)
10 top web development frameworks (new version 21 11)
 
Frontend Development Bootcamp - React [Online & Offline] In Bangla
Frontend Development Bootcamp - React [Online & Offline] In BanglaFrontend Development Bootcamp - React [Online & Offline] In Bangla
Frontend Development Bootcamp - React [Online & Offline] In Bangla
 
Difference between ajax and silverlight
Difference between ajax and silverlightDifference between ajax and silverlight
Difference between ajax and silverlight
 
Aeternity Blockchain - Ecosystem & Devtools [2019]
Aeternity Blockchain - Ecosystem & Devtools [2019]Aeternity Blockchain - Ecosystem & Devtools [2019]
Aeternity Blockchain - Ecosystem & Devtools [2019]
 
Vitaliy Kryvonos_CV_up
Vitaliy Kryvonos_CV_upVitaliy Kryvonos_CV_up
Vitaliy Kryvonos_CV_up
 
Building a Next Generation Mobile Browser using Web technologies
Building a Next Generation Mobile Browser using Web technologiesBuilding a Next Generation Mobile Browser using Web technologies
Building a Next Generation Mobile Browser using Web technologies
 
Top Web Development Frameworks Comparison: All You Need To Know
Top Web Development Frameworks Comparison: All You Need To KnowTop Web Development Frameworks Comparison: All You Need To Know
Top Web Development Frameworks Comparison: All You Need To Know
 
Hai_Bui
Hai_BuiHai_Bui
Hai_Bui
 
Angular Rebooted: Components Everywhere
Angular Rebooted: Components EverywhereAngular Rebooted: Components Everywhere
Angular Rebooted: Components Everywhere
 
Building Desktop RIAs with PHP, HTML & Javascript in AIR
Building Desktop RIAs with PHP, HTML & Javascript in AIRBuilding Desktop RIAs with PHP, HTML & Javascript in AIR
Building Desktop RIAs with PHP, HTML & Javascript in AIR
 
Single Page Application Best practices
Single Page Application Best practicesSingle Page Application Best practices
Single Page Application Best practices
 
Education&work experience
Education&work experienceEducation&work experience
Education&work experience
 
Portfolio
PortfolioPortfolio
Portfolio
 
React vs. angular a comprehensive guideline for choosing right front-end fr...
React vs. angular   a comprehensive guideline for choosing right front-end fr...React vs. angular   a comprehensive guideline for choosing right front-end fr...
React vs. angular a comprehensive guideline for choosing right front-end fr...
 
Sencha touchonbb10 bootcamp
Sencha touchonbb10 bootcampSencha touchonbb10 bootcamp
Sencha touchonbb10 bootcamp
 

Similar to Frontend Monoliths: Run if you can!

Die Qual der Wahl bei den Single Page Application Frameworks
Die Qual der Wahl bei den Single Page Application FrameworksDie Qual der Wahl bei den Single Page Application Frameworks
Die Qual der Wahl bei den Single Page Application FrameworksJonas Bandi
 
Top Cordova Challenges and How to Tackle Them
Top Cordova Challenges and How to Tackle ThemTop Cordova Challenges and How to Tackle Them
Top Cordova Challenges and How to Tackle ThemIonic Framework
 
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - RecifeThe challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - RecifeCaridy Patino
 
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...Shift Conference
 
Developing of a high load java script framework
Developing of a high load java script frameworkDeveloping of a high load java script framework
Developing of a high load java script frameworkMikita Manko
 
IRJET- Polymer Javascript
IRJET- Polymer JavascriptIRJET- Polymer Javascript
IRJET- Polymer JavascriptIRJET Journal
 
FEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing MojitoFEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing MojitoCaridy Patino
 
Phonegap Development & Debugging
Phonegap Development & DebuggingPhonegap Development & Debugging
Phonegap Development & DebuggingIvano Malavolta
 
Building a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one weekBuilding a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one weekDr. Felix Raab
 
Django simplified : by weever mbakaya
Django simplified : by weever mbakayaDjango simplified : by weever mbakaya
Django simplified : by weever mbakayaMbakaya Kwatukha
 
An overview of the architecture of electron.js
An overview of the architecture of electron.jsAn overview of the architecture of electron.js
An overview of the architecture of electron.jsMoon Technolabs Pvt. Ltd.
 
Angular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraAngular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraLINAGORA
 
Anatomy of an HTML 5 mobile web app
Anatomy of an HTML 5 mobile web app Anatomy of an HTML 5 mobile web app
Anatomy of an HTML 5 mobile web app Ivano Malavolta
 

Similar to Frontend Monoliths: Run if you can! (20)

Die Qual der Wahl bei den Single Page Application Frameworks
Die Qual der Wahl bei den Single Page Application FrameworksDie Qual der Wahl bei den Single Page Application Frameworks
Die Qual der Wahl bei den Single Page Application Frameworks
 
Top Cordova Challenges and How to Tackle Them
Top Cordova Challenges and How to Tackle ThemTop Cordova Challenges and How to Tackle Them
Top Cordova Challenges and How to Tackle Them
 
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - RecifeThe challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
 
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
 
Micro Front Ends : Divided We Rule by Parth Ghiya - AhmedabadJS
Micro Front Ends : Divided We Rule by Parth Ghiya - AhmedabadJSMicro Front Ends : Divided We Rule by Parth Ghiya - AhmedabadJS
Micro Front Ends : Divided We Rule by Parth Ghiya - AhmedabadJS
 
Web Components and PWA
Web Components and PWAWeb Components and PWA
Web Components and PWA
 
Developing of a high load java script framework
Developing of a high load java script frameworkDeveloping of a high load java script framework
Developing of a high load java script framework
 
IRJET- Polymer Javascript
IRJET- Polymer JavascriptIRJET- Polymer Javascript
IRJET- Polymer Javascript
 
FEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing MojitoFEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing Mojito
 
Apache cordova
Apache cordovaApache cordova
Apache cordova
 
Don't screw it up! How to build durable API
Don't screw it up! How to build durable API Don't screw it up! How to build durable API
Don't screw it up! How to build durable API
 
Presemtation Tier Optimizations
Presemtation Tier OptimizationsPresemtation Tier Optimizations
Presemtation Tier Optimizations
 
Micro frontends
Micro frontendsMicro frontends
Micro frontends
 
Phonegap Development & Debugging
Phonegap Development & DebuggingPhonegap Development & Debugging
Phonegap Development & Debugging
 
Building a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one weekBuilding a full-stack app with Golang and Google Cloud Platform in one week
Building a full-stack app with Golang and Google Cloud Platform in one week
 
Django simplified : by weever mbakaya
Django simplified : by weever mbakayaDjango simplified : by weever mbakaya
Django simplified : by weever mbakaya
 
PWA
PWAPWA
PWA
 
An overview of the architecture of electron.js
An overview of the architecture of electron.jsAn overview of the architecture of electron.js
An overview of the architecture of electron.js
 
Angular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraAngular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - Linagora
 
Anatomy of an HTML 5 mobile web app
Anatomy of an HTML 5 mobile web app Anatomy of an HTML 5 mobile web app
Anatomy of an HTML 5 mobile web app
 

Recently uploaded

Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 

Recently uploaded (20)

Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 

Frontend Monoliths: Run if you can!

  • 2. In 2016 the average webpage size passed the size of Doom https://mobiforge.com/research-analysis/the-web-is-doom
  • 3. Web-Page Obesity The first Mac had 128k of RAM in 1984.
  • 4. Web: Size does Matter!
  • 5. The Cost of JavaScript optional ajax request data http://thedomain:80/app http://thedomain:80/api/data/first http://thedomain:80/app#/first http://thedomain:80/app#/second "navigate" to "first" screen http://thedomain:80/app#/first navigation Browser Serverinitial request html-shell assets load data & render screen with JS "navigate" to "second" screen load data & render screen with JS html-shell is loaded optional ajax request http://thedomain:80/api/data/second data loading... appbootstrapping Network CostCPU Cost
  • 6. The Cost of JavaScript https://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d4 For mobile, aim for a JS budget of < 170KB minified/compressed.
  • 7. Server Side Rendering http://thedomain:80/app http://thedomain:80/app#/first Browser Serverinitial request html-shell assets html-shell 
 is displayedloading... Angular renders 
 the page run JS http://thedomain:80/app/first http://thedomain:80/app/first Browser Serverinitial request html-shell
 with content assets rendered page is displayed Angular is bootstrapped 
 on the page run JS Angular renders 
 the page run JS Traditional SPA: Enabling Server Side Rendering: https://angular.io/guide/router#appendix-locationstrategy-and-browser-url-styles
  • 8. Time to Paint vs.Time to Interactive https://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d4
  • 10. Speed == Money https://www.thinkwithgoogle.com/feature/mobile/ Amazon did tests that showed they would lose $1.6 BILLION every year if they slowed down by just one second. Walmart Study: For every 100 ms of improvement, they grew incremental revenue by up to 1%. https://www.fastcompany.com/1825005/how-one-second-could-cost-amazon-16-billion-sales https://blog.radware.com/applicationdelivery/wpo/2014/04/web-page-speed-affect-conversions-infographic/
  • 12. History of Enterprise Apps • Rich Clients accessing the DB • Server-Side Web with multiple Domains • Moving to SPA -> enables Microservices • Eclipse RCP "Workbenches" -> Moving to Web
  • 13. The Fat Client Feature 1 Feature 2 Feature 2 Rich Client
  • 14. Workbench & Monolith Feature 1 Feature 2 Feature 2 Workbench Monolithic Server Feature 1 Feature 2 Feature 3
  • 15. Traditional Web Monolith Feature 1 Feature 2 Feature 3 Frontend Browser Monolithic Server
  • 16. SPA Monolith Feature 1 Feature 2 Feature 3 Frontend Monolithic Server
  • 17. SPA Monolith & Microservices Feature 1 Feature 2 Feature 3 Frontend API API API Composition & Orchestration happens in the Client
  • 18. Rich Client Migrations: 
 The Rise of the Monoliths API Workbench Monolithic Server Feature 1 Feature 2 Feature 3 Feature 1 Feature 2 Feature 3 Feature 1 API Feature 1 API Feature 1 SPA Monolith App
  • 19. API Workbench Monolithic Server Feature 1 Feature 2 Feature 3 Feature 1 Feature 2 Feature 3 Feature 1 API Feature 1 API Feature 1 SPA Monolith App Improvement! Much Worse!
  • 20. Beware of the Monolith Unfortunately, we've seen many teams create front-end monoliths - a single, large and sprawling browser application - on top of their back-end services. -ThoughtWorksTechnology Radar App1 App2 App3 API 1 API 2 API 3 SPA Monolith
  • 21. Problems of the Frontend Monolith • Performance 
 -> size is still relevant for web applications! • Coupling & Dependencies • preventing change / agility / time to market • preventing effective/simple organization
 (effective end-to-end delivery, self organizing teams ...)
  • 22. Coupling / Lock-Step Releases "Think about the granularity of development & deployment artifacts" Application 1 - implemented by team 1 - driven by org-unit 1 Application 2 - implemented by team 2 - driven by org-unit 2 shared lib - inhouse lib - 3rd party lib 
 (ie. Angular, React) team 2 needs to change or update the lib team 1 is immediately affected The consequence is coupling between App1 and App 2: - teams have to coordinate changes to the shared lib. - development & release schedules of applications are coupled Who is responsible for testing/fixing application 1? release release release release release release
  • 23. Problems of the Frontend Monolith • The web is traditionally not made for complex applications • global scope / no isolation / no modularization concepts • extremely dynamic (typing, monkey paching ...) • browser differences • Frequent technology changes • core technologies are very backwards compatible • ecosystem moves at break-neck speed
  • 25.
  • 27. The first rule of huge 
 enterprise applications is: 
 You do not build huge enterprise applications.
  • 28. The second rule of huge enterprise applications is: You do not build huge enterprise applications.
  • 29. How?
  • 30. Micro Frontends: An architectural style where independently deliverable frontend applications are composed into a greater whole.
  • 31. ?
  • 32. Micro Frontends App 1 App 2 App 3 App API 1 API 2 API 3 SPA Monolith API 1 API 2 API 3 ? ? The million dollar question:
 Modularizing frontend applications. https://micro-frontends.org/
  • 33. The Link <a href="..." > The magical integration pattern that the web is built upon:
  • 34. Microfrontend Flavors: Mini SPAs Feature 1 Feature 2 Feature 3 App 1 API API API App 2 App 3 Page Page PageLink Link You have complete isolation. But jumping between apps is a full page load!
  • 36. Challenges • Performance: Starting the Mini-SPAs has to be very quick! • Sharing layout & styles for common UX
 -> use reusable technologies for styling -> plain CSS, SASS, less ...
 -> be careful with "framework-specific" styling • Sharing state / context
 -> query parameters, cookies, http-headers
 -> server side session / context
 -> Local Storage / Indexed DB Feature 1 App 1 Page Link App2 Page Feature 1 Context
  • 38. Frameworks could matter ... Transfer size (KB) for the same application  https://medium.freecodecamp.org/a-real-world-comparison-of-front-end-frameworks-with-benchmarks-2018-update-e5760fb4a962
  • 39. Keep an eye on your bundles! source-map-explorer:
 https://www.npmjs.com/package/source-map-explorer webpack-bundle-analyzer:
 https://github.com/webpack-contrib/webpack-bundle-analyzer npm install -g source-map-explorer ng build --prod --source-map source-map-explorer dist/ng-app/main.XYZ.js npm install -g webpack-bundle-analyzer ng build --prod --stats-json webpack-bundle-analyzer dist/ng-app/stats.json www.bundlephobia.com
  • 40. But I need a single SPA!
  • 41. Microfrontend Flavors: Sinlge SPA Feature 1 Feature 2 Feature 3 App 1 API API API App 2 App 3 Shell D0M D0M https://github.com/CanopyTax/single-spa All applications live on the same DOM. App-communication happens over the DOM.
  • 42. You will need a shell • Top-level routing • Lazy loading of apps (child SPAs) • Inter-SPA communication • Sharing a context
  • 43. Sinlge SPA: iframes Feature 1 Feature 2 Feature 3 App 1 API API API App 2 App 3 Shell dependencies dependencies dependencies D0M D0M Analogy: complete classloader isolation. Browser can leverage caching, but for each app all dependencies have to be parsed, compiled and executed. iframeiframeiframe
  • 44. Option: "Child SPAs" in iframe Advantages: - true isolation - integration of "non-SPA" applications / sites Disadvantage: - No isolation: same global DOM, same scripting context, same global scope - Responsive layout is difficult - Router can't access the URL - Some 3rd party libraries break, since they depend on document events
  • 45. Sinlge SPA: Isolated Feature 1 Feature 2 Feature 3 App 1 API API API App 2 App 3 Shell dependencies dependencies dependencies D0M D0M Browser can leverage caching, but for each app all dependencies have to be parsed, compiled and executed. Like "complete classloader isolation", but only if the app & dependencies don't pollute the global scope. 
 Note:Angular comes with Zone.js, which heavily pollutes the global scope!
  • 48. Sinlge SPA: Shared Dependencies Feature 1 Feature 2 Feature 3 App 1 API API API App 2 App 3 Shell shared dependencies D0M D0M Analogy: shared classloader
  • 52. Frontend Composition Feature 1 Feature 2 Feature 3 App 1 API API API App 2 App 3 Shell
  • 53. How?
  • 54. Web Components Custom Elements API: customElements.define('element-details', class extends HTMLElement { ... }) WebComponents is a series of browser standards for creating reusable custom elements: https://developer.mozilla.org/en-US/docs/Web/Web_Components
 https://developer.mozilla.org/en-US/docs/Web/API/Window/customElements Shadow DOM Encapsulation HTML templates markup that is not initially rendered and can be instantiated. Custom elements JavaScript API to define custom elements that can be used in html and their behavior JavaScript html: <div> <element-details></element-details> <div> Browser support: native: Chrome, Safari polyfill: Firefox, Edge, IE11
  • 55.
  • 57. Angular Elements https://angular.io/guide/elements Using Angular components as Web Components. Angular Elements can transform Angular components into classes that can be registers as custom elemements: import { createCustomElement } from '@angular/elements'; import { PopupComponent } from './popup.component'; const PopupElement = createCustomElement(PopupComponent, {injector}); customElements.define('element-details', PopupElement) Available in Angular 6 in any html (also from React JSX andVue templates): <div> <element-details></element-details> <div>
  • 58. Vue CLI Compilation Vue CLI 3 can wrap a vue component / app inside a Web Component https://cli.vuejs.org/guide/build-targets.html#web-component 
 https://github.com/vuejs/vue-web-component-wrapper vue-cli-service build --target wc --name my-element ./main.js Build: <script src="path/to/my-element.js"></script> ... <my-element></my-element> any html:
  • 61. More than ever: Size does Matter!
  • 62. Size Does Matter! Feature 1 Feature 2 Feature 3 App 1 API API API App 2 App 3 Shell 670KB 430KB 932KB
  • 63. Size Does Matter! Feature 1 Feature 2 Feature 3 App 1 API API API App 2 App 3 Shell 30KB 35KB 120KB Angular React Vue 300KB 65KB 80KB
  • 64. Big & Independent 
 vs. 
 Small & Coupled
  • 65. More Challenges Dataflow & sharing state between components: Applications do not just consist of simple components.
 There is shared state & context
 (Angular services, React context, Redux stores ...) WebComponents just have primitive string properties! Versioning:There is no versioning of custom elements! "It feels like imperative DOM programming" (remember jQuery?)
  • 66. There is no Silver Bullet for 
 Frontend Modularization
  • 67. Fragen? JavaScript / Angular / React Schulungen & Coachings,
 Project-Setup & Proof-of-Concept: http://ivorycode.com/#schulung
 jonas.bandi@ivorycode.com https://github.com/jbandi/sbb-dev-day-2018