SlideShare a Scribd company logo
An overview of
Scalable Web Application Front-end
Saeid Zebardast
http://zebardast.com
@saeidzeb
1
An overview of Scalable Web Application Front-end
Problem Definition
Building large web applications with dozens of developers is a difficult task. Organizing the engineers
around a common goal is one thing, but organizing your code so that people can work efficiently is
another. Many large applications suffer from growing pains after just a few months in production due to
poorly designed JavaScript with unclear upgrade and extension paths.
Scalable JavaScript Application Framework
Yahoo! home page engineer Nicholas Zakas1
, author of Professional JavaScript for Web Developers,
introduced front-end architecture for complex, modular web applications with significant JavaScript
elements.
1 nczonline.net
2
Figure 1: Scalable JavaScript Application Architecture by N. Zakas
Module
An independent unit of functionality that is part of the total structure of a web application. Web
application modules consist of HTML, CSS and JavaScript.
Module rules
• Any single module should be able to live on its own
• Loose coupling allows you to make changes to one module without affecting the others
• Each module has its own sandbox
◦ An interface with which the module can interact to ensure loose coupling
• Modules have limited knowledge and only know the sandbox
◦ Each module knows about their sandbox and that's it The rest of the architecture doesn't
exist to them.
• Only call your own methods or those on the sandbox
• Don't access DOM elements outside of your box
• Don't access non-native global objects
• Anything else you need, ask the sandbox
• Don't create global objects
• Don't directly reference other modules
• Modules must stay within their own sandboxes
◦ No matter how restrictive or uncomfortable it may seem
Sandbox
The sandbox ensures a consistent interface. Modules can rely on the methods to always be there. The
sandbox also acts like a security guard. It knows what the modules are allowed to access and do on the
framework.
Sandbox jobs
• Consistency
• Security
• Communication
3
Application Core
The application core manages modules. The application core tells a module when it should initialize
and when it should shutdown. Also, it manages communication between modules.
The application core handles errors. It uses available information to determine best course of action.
Application core jobs
• Manage module lifecycle
• Enable inter-module communication
• General error handling
• Be extensible by plugins
Mediator
The application core handles the messages by using Mediator class.
Plugins
Plugins augment the capabilities of the core to keep it relevant and useful. Anything built for extension
can never be obsolete.
What plugins can be created
• Error handling
• Ajax communication
• New module capabilities
• General utilities
• Anything!
Base Library
The base library provides basic functionality. Most applications are too tightly coupled to the base
library. Developers get upset when they can't touch the base library. Ideally, only the application core
has any idea what base library is being used.
4
Base library jobs
• Browser normalization
• General purpose utilities
◦ Parsers/Serializers for XML, JSON, etc.
◦ Object manipulation
◦ DOM manipulation
◦ Ajax communication
• Provide low-level extensibility
Advantages
• Multiple different applications can be created with the same framework.
• Each part can be tested separately
5
What's “scaleApp”?
scaleApp2
is a tiny JavaScript framework for scalable JavaScript Applications. The framework allows
you to easily create complex web applications. scaleApp is based on a decoupled, event-driven
architecture that is inspired by the talk of Nicholas C. Zakas - "Scalable JavaScript Application
Architecture".
Quick start using “scaleApp”?
Link scaleApp.min.js in your HTML file:
<script src="scaleApp.min.js"></script>
Create a core
First of all create a new core instance:
var core = new scaleApp.Core();
Register modules
core.register( "myModuleId", function( sandbox ){
return {
init: function(){ /*...*/ },
destroy: function(){ /*...*/ }
};
});
As you can see the module is a function that takes the sandbox as a parameter and returns an object that
has two functions init and destroy (the latter is optional). Of course your module can be any usual class
with those two functions.
var MyGreatModule = function(sandbox){
return {
2 http://scaleapp.org
6
init: function(){ alert("Hello world!"); }
destroy: function(){ alert("Bye bye!"); }
};
};
core.register("myGreatModule", MyGreatModule);
The init function is called by the framework when the module is supposed to start. The destroy function
is called when the module has to shut down.
Start modules
After your modules are registered, start your modules:
core
.start( "myModuleId" )
.start( "anOtherModule", function(err){
// 'anOtherModule' is running now
});
Stopping
It's obvious:
core.stop("moduleB");
core.stop(); // stops all running instances
Publish/Subscribe
If the module needs to communicate with others, you can use the emit and on methods.
7
Emit
The emit function takes three parameters whereas the last one is optional:
• topic: the channel name you want to emit to
• data: the data itself
• cb: callback method
The emit function is accessible through the sandbox:
sandbox.emit( "myEventTopic", myData );
On
A message handler could look like this:
var messageHandler = function( data, topic ){
switch( topic ){
case "somethingHappend":
sandbox.emit( "myEventTopic", processData(data) );
break;
case "aNiceTopic":
justProcess( data );
break;
}
};
… and it can listen to one or more channels:
sub1 = sandbox.on( "somethingHappend", messageHandler );
sub2 = sandbox.on( "aNiceTopic", messageHandler );
8
Attach and Detach
A subscription can be detached and attached again:
sub.detach(); // don't listen any more
sub.attach(); // receive upcoming messages
Unsubscribe
You can unsubscribe a function from channel:
sandbox.off("a-channel", callback);
And you can remove a callback function from all channels:
sandbox.off(callback);
Or remove all subscriptions from a channel:
sandbox.off("channelName");
9

More Related Content

What's hot (14)

PDF
Android Architecture Components
Darshan Parikh
 
PPT
Javascript Frameworks
Mitesh Gandhi
 
PPTX
Mvvm knockout vs angular
Basarat Syed
 
PDF
Choosing the best JavaScript framework/library/toolkit
Hristo Chakarov
 
PDF
Introduction to React and Flux (CodeLabs)
Eueung Mulyana
 
PPT
Struts course material
Vibrant Technologies & Computers
 
PDF
CRUD with Polymer 2.0
Manuel Carrasco Moñino
 
PPTX
Selenium Online Training
Learntek1
 
PDF
Getting Started with Spring Framework
Edureka!
 
PPSX
Spring - Part 4 - Spring MVC
Hitesh-Java
 
PDF
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
DicodingEvent
 
PPTX
Backbone And Marionette : Take Over The World
harshit040591
 
PDF
Cleaning your architecture with android architecture components
Debora Gomez Bertoli
 
PDF
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
Sencha
 
Android Architecture Components
Darshan Parikh
 
Javascript Frameworks
Mitesh Gandhi
 
Mvvm knockout vs angular
Basarat Syed
 
Choosing the best JavaScript framework/library/toolkit
Hristo Chakarov
 
Introduction to React and Flux (CodeLabs)
Eueung Mulyana
 
Struts course material
Vibrant Technologies & Computers
 
CRUD with Polymer 2.0
Manuel Carrasco Moñino
 
Selenium Online Training
Learntek1
 
Getting Started with Spring Framework
Edureka!
 
Spring - Part 4 - Spring MVC
Hitesh-Java
 
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
DicodingEvent
 
Backbone And Marionette : Take Over The World
harshit040591
 
Cleaning your architecture with android architecture components
Debora Gomez Bertoli
 
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
Sencha
 

Viewers also liked (7)

PDF
What is good design?
Saeid Zebardast
 
PDF
Introduction to Redis
Saeid Zebardast
 
PDF
Web Components Revolution
Saeid Zebardast
 
PDF
MySQL Cheat Sheet
Saeid Zebardast
 
PDF
An Introduction to Apache Cassandra
Saeid Zebardast
 
PDF
Java Cheat Sheet
Saeid Zebardast
 
PDF
Less, But Better - Dieter Rams' Principles of Good Design
3Pillar Global
 
What is good design?
Saeid Zebardast
 
Introduction to Redis
Saeid Zebardast
 
Web Components Revolution
Saeid Zebardast
 
MySQL Cheat Sheet
Saeid Zebardast
 
An Introduction to Apache Cassandra
Saeid Zebardast
 
Java Cheat Sheet
Saeid Zebardast
 
Less, But Better - Dieter Rams' Principles of Good Design
3Pillar Global
 
Ad

Similar to An overview of Scalable Web Application Front-end (20)

PDF
ascitconsultancy-scalable-javascript-application-architecture for ascitconsul...
Carmor Bass
 
PDF
Scalable JavaScript Application Architecture
Nicholas Zakas
 
PDF
Built to Last
Dan Lynch
 
PDF
Building Scalable JavaScript Apps
Gil Fink
 
PDF
Large-Scale JavaScript Development
Addy Osmani
 
PDF
NodeJS
LinkMe Srl
 
PDF
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
Fwdays
 
PPTX
Scalable JavaScript Application Architecture 2012
Nicholas Zakas
 
PDF
Building a JavaScript Module Framework at Gilt
Eric Shepherd
 
PDF
Building Enterprise Grade Front-End Applications with JavaScript Frameworks
FITC
 
PDF
Building Large Scale Javascript Application
Anis Ahmad
 
PDF
Node frameworks talk_hackerdojo
Shubhra Kar
 
PDF
Introduction to nodejs
James Carr
 
PDF
Building businesspost.ie using Node.js
Richard Rodger
 
PDF
Introducing Applitude: Simple Module Management
Eric Hamilton
 
PDF
Best practices for creating modular Web applications
peychevi
 
PPT
Node js
Chirag Parmar
 
KEY
20120306 dublin js
Richard Rodger
 
PDF
SPA: Key Questions
Volodymyr Voytyshyn
 
PDF
Front end-modernization
ColdFusionConference
 
ascitconsultancy-scalable-javascript-application-architecture for ascitconsul...
Carmor Bass
 
Scalable JavaScript Application Architecture
Nicholas Zakas
 
Built to Last
Dan Lynch
 
Building Scalable JavaScript Apps
Gil Fink
 
Large-Scale JavaScript Development
Addy Osmani
 
NodeJS
LinkMe Srl
 
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
Fwdays
 
Scalable JavaScript Application Architecture 2012
Nicholas Zakas
 
Building a JavaScript Module Framework at Gilt
Eric Shepherd
 
Building Enterprise Grade Front-End Applications with JavaScript Frameworks
FITC
 
Building Large Scale Javascript Application
Anis Ahmad
 
Node frameworks talk_hackerdojo
Shubhra Kar
 
Introduction to nodejs
James Carr
 
Building businesspost.ie using Node.js
Richard Rodger
 
Introducing Applitude: Simple Module Management
Eric Hamilton
 
Best practices for creating modular Web applications
peychevi
 
Node js
Chirag Parmar
 
20120306 dublin js
Richard Rodger
 
SPA: Key Questions
Volodymyr Voytyshyn
 
Front end-modernization
ColdFusionConference
 
Ad

More from Saeid Zebardast (7)

PDF
Developing Applications with MySQL and Java for beginners
Saeid Zebardast
 
PDF
Java for beginners
Saeid Zebardast
 
PDF
MySQL for beginners
Saeid Zebardast
 
PDF
هفده اصل افراد موثر در تیم
Saeid Zebardast
 
PDF
How to be different?
Saeid Zebardast
 
PDF
What is REST?
Saeid Zebardast
 
PDF
معرفی گنو/لینوکس و سیستم عامل های متن باز و آزاد
Saeid Zebardast
 
Developing Applications with MySQL and Java for beginners
Saeid Zebardast
 
Java for beginners
Saeid Zebardast
 
MySQL for beginners
Saeid Zebardast
 
هفده اصل افراد موثر در تیم
Saeid Zebardast
 
How to be different?
Saeid Zebardast
 
What is REST?
Saeid Zebardast
 
معرفی گنو/لینوکس و سیستم عامل های متن باز و آزاد
Saeid Zebardast
 

Recently uploaded (20)

PPSX
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
PDF
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PDF
Database Benchmarking for Performance Masterclass: Session 1 - Benchmarking F...
ScyllaDB
 
PDF
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
PDF
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PDF
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PDF
Why aren't you using FME Flow's CPU Time?
Safe Software
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
UiPath Agentic AI ile Akıllı Otomasyonun Yeni Çağı
UiPathCommunity
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PPTX
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
PDF
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
PDF
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
PPTX
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
PDF
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
Database Benchmarking for Performance Masterclass: Session 1 - Benchmarking F...
ScyllaDB
 
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
Why aren't you using FME Flow's CPU Time?
Safe Software
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
UiPath Agentic AI ile Akıllı Otomasyonun Yeni Çağı
UiPathCommunity
 
Kubernetes - Architecture & Components.pdf
geethak285
 
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 

An overview of Scalable Web Application Front-end

  • 1. An overview of Scalable Web Application Front-end Saeid Zebardast http://zebardast.com @saeidzeb 1
  • 2. An overview of Scalable Web Application Front-end Problem Definition Building large web applications with dozens of developers is a difficult task. Organizing the engineers around a common goal is one thing, but organizing your code so that people can work efficiently is another. Many large applications suffer from growing pains after just a few months in production due to poorly designed JavaScript with unclear upgrade and extension paths. Scalable JavaScript Application Framework Yahoo! home page engineer Nicholas Zakas1 , author of Professional JavaScript for Web Developers, introduced front-end architecture for complex, modular web applications with significant JavaScript elements. 1 nczonline.net 2 Figure 1: Scalable JavaScript Application Architecture by N. Zakas
  • 3. Module An independent unit of functionality that is part of the total structure of a web application. Web application modules consist of HTML, CSS and JavaScript. Module rules • Any single module should be able to live on its own • Loose coupling allows you to make changes to one module without affecting the others • Each module has its own sandbox ◦ An interface with which the module can interact to ensure loose coupling • Modules have limited knowledge and only know the sandbox ◦ Each module knows about their sandbox and that's it The rest of the architecture doesn't exist to them. • Only call your own methods or those on the sandbox • Don't access DOM elements outside of your box • Don't access non-native global objects • Anything else you need, ask the sandbox • Don't create global objects • Don't directly reference other modules • Modules must stay within their own sandboxes ◦ No matter how restrictive or uncomfortable it may seem Sandbox The sandbox ensures a consistent interface. Modules can rely on the methods to always be there. The sandbox also acts like a security guard. It knows what the modules are allowed to access and do on the framework. Sandbox jobs • Consistency • Security • Communication 3
  • 4. Application Core The application core manages modules. The application core tells a module when it should initialize and when it should shutdown. Also, it manages communication between modules. The application core handles errors. It uses available information to determine best course of action. Application core jobs • Manage module lifecycle • Enable inter-module communication • General error handling • Be extensible by plugins Mediator The application core handles the messages by using Mediator class. Plugins Plugins augment the capabilities of the core to keep it relevant and useful. Anything built for extension can never be obsolete. What plugins can be created • Error handling • Ajax communication • New module capabilities • General utilities • Anything! Base Library The base library provides basic functionality. Most applications are too tightly coupled to the base library. Developers get upset when they can't touch the base library. Ideally, only the application core has any idea what base library is being used. 4
  • 5. Base library jobs • Browser normalization • General purpose utilities ◦ Parsers/Serializers for XML, JSON, etc. ◦ Object manipulation ◦ DOM manipulation ◦ Ajax communication • Provide low-level extensibility Advantages • Multiple different applications can be created with the same framework. • Each part can be tested separately 5
  • 6. What's “scaleApp”? scaleApp2 is a tiny JavaScript framework for scalable JavaScript Applications. The framework allows you to easily create complex web applications. scaleApp is based on a decoupled, event-driven architecture that is inspired by the talk of Nicholas C. Zakas - "Scalable JavaScript Application Architecture". Quick start using “scaleApp”? Link scaleApp.min.js in your HTML file: <script src="scaleApp.min.js"></script> Create a core First of all create a new core instance: var core = new scaleApp.Core(); Register modules core.register( "myModuleId", function( sandbox ){ return { init: function(){ /*...*/ }, destroy: function(){ /*...*/ } }; }); As you can see the module is a function that takes the sandbox as a parameter and returns an object that has two functions init and destroy (the latter is optional). Of course your module can be any usual class with those two functions. var MyGreatModule = function(sandbox){ return { 2 http://scaleapp.org 6
  • 7. init: function(){ alert("Hello world!"); } destroy: function(){ alert("Bye bye!"); } }; }; core.register("myGreatModule", MyGreatModule); The init function is called by the framework when the module is supposed to start. The destroy function is called when the module has to shut down. Start modules After your modules are registered, start your modules: core .start( "myModuleId" ) .start( "anOtherModule", function(err){ // 'anOtherModule' is running now }); Stopping It's obvious: core.stop("moduleB"); core.stop(); // stops all running instances Publish/Subscribe If the module needs to communicate with others, you can use the emit and on methods. 7
  • 8. Emit The emit function takes three parameters whereas the last one is optional: • topic: the channel name you want to emit to • data: the data itself • cb: callback method The emit function is accessible through the sandbox: sandbox.emit( "myEventTopic", myData ); On A message handler could look like this: var messageHandler = function( data, topic ){ switch( topic ){ case "somethingHappend": sandbox.emit( "myEventTopic", processData(data) ); break; case "aNiceTopic": justProcess( data ); break; } }; … and it can listen to one or more channels: sub1 = sandbox.on( "somethingHappend", messageHandler ); sub2 = sandbox.on( "aNiceTopic", messageHandler ); 8
  • 9. Attach and Detach A subscription can be detached and attached again: sub.detach(); // don't listen any more sub.attach(); // receive upcoming messages Unsubscribe You can unsubscribe a function from channel: sandbox.off("a-channel", callback); And you can remove a callback function from all channels: sandbox.off(callback); Or remove all subscriptions from a channel: sandbox.off("channelName"); 9