SlideShare a Scribd company logo
1 of 34
Download to read offline
Vrije Universiteit Amsterdam
Vrije Universiteit Amsterdam
A software built with web technologies that is accessible via a
mobile browser
The browser may be either
the standard device browser
or an embedded browser
(hybrid app)
Vrije Universiteit Amsterdam
Goal of HTML5 code is to represent
the structure and contents of the
web page
You can see it as a passive container
of data to be presented to the user
When the user interacts with the
display, it triggers events managed
by the JavaScript code
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body>
…
</body>
</html>
Vrije Universiteit Amsterdam
<form action="/computeResult.php" method="post" name="myform">
Enter a value :
<input type="text" name="name" />
<input type="email" name="email" />
<input type="number" name="phone" />
<input type="date" name="birthdate" />
<input type="button" value="Send" />
</form>
Vrije Universiteit Amsterdam
Describes how HTML elements are to be displayed
External stylesheets are stored in CSS files
with CSS without CSS
Vrije Universiteit Amsterdam
A couple of examples...
Vrije Universiteit Amsterdam
JavaScript is the programming code that can be
inserted into HTML pages
○ it can react to events in the DOM
○ it can modify the DOM
Interpreted language
○ see the eval() function
JavaScript HAS NOTHING TO DO WITH Java
Vrije Universiteit Amsterdam
Quick example
Vrije Universiteit Amsterdam
Every time the app calls the server, it renders a new HTML page
e.g., standard PHP websites
https://goo.gl/3d1eX6
Vrije Universiteit Amsterdamhttps://goo.gl/3d1eX6
● The application logic is inside a single HTML page
● Data is displayed by updating the HTML DOM in place
○ more fluid w.r.t. a page refresh
● Data is retrieved from the application server using JavaScript
Vrije Universiteit Amsterdam
Vrije Universiteit Amsterdam
● Web app
○ Acts as a client for user interaction
● Application server
○ Receives requests from the app (usually HTTP messages)
○ Handles business logic
○ Fetches data from the data repo
○ Provides data to apps (with XML or JSON payload)
● Data repository
○ Stores raw data
○ Mainly passive
Vrije Universiteit Amsterdam
Mobile web apps:
● do not work offline
● no background activities
○ e.g., geofencing
● poor distribution (no app store)
● they are launched via a browser
● poor access to system APIs
○ push notifications, camera, contacts, etc.
● can be unsecure
Vrije Universiteit Amsterdam
Pros:
● rich user interfaces and/or heavy graphics
● work offline,
● ...
Cons:
● FRAGMENTATION
○ development and maintainability costs
● slow iteration pace (stores mediation)
● no indexing by search engines
● no portability
○ an app cannot be deployed on other platforms
Vrije Universiteit Amsterdam
Progressive web apps
(PWA)
Vrije Universiteit Amsterdam
INTUITION: to combine the best of web and native apps
A PWA is a web app, its life starts as a browser tab
→ no install required, then it becomes an app
PWAs can work offline
Live in a server → no update distribution delays
Support push notifications
Live in the home screen of the mobile device
Load as top-level, full screen experiences (no browser tabs)
Vrije Universiteit Amsterdam
1. The user accesses the website as usual
○ It does not do anything special, but it
has already PWA features like TLS,
service workers, manifests, and
responsive design
Vrije Universiteit Amsterdam
1. The user accesses the website as usual
○ It does not do anything special, but it
has already PWA features like TLS,
service workers, manifests, and
responsive design
2. After the 3rd-4th visit, a prompt is shown
○ The prompt is populated from the
Manifest
https://goo.gl/KIZydg
Vrije Universiteit Amsterdam
1. The user accesses the website as usual
○ It does not do anything special, but it
has already PWA features like TLS,
service workers, manifests, and
responsive design
2. After the 3rd-4th visit, a prompt is shown
○ The prompt is populated from the
Manifest
3. The user can decide to add the app to the
home screen or app launcher
https://goo.gl/KIZydg
Vrije Universiteit Amsterdam
1. The user accesses the website as usual
○ It does not do anything special, but it
has already PWA features like TLS,
service workers, manifests, and
responsive design
2. After the 3rd-4th visit, a prompt is shown
○ The prompt is populated from the
Manifest
3. The user can decide to add the app to the
home screen or app launcher
4. When launched from the home screen, the
app is top-level, full-screen, and can receive
push notifications
https://goo.gl/KIZydg
Vrije Universiteit Amsterdam
https://developers.google.com/web/showcase/
Check it yourself:
chrome://serviceworker-internals/
Vrije Universiteit Amsterdam
A website can be considered a PWA if:
1. it is served over HTTPS
○ this is a requirement for avoiding man-in-the-middle attacks
2. it comes with a Manifest file
○ it declares app name, icon, base URL, etc.
3. it uses service workers
○ a set of APIs for allowing the developer to safely cache and preload data,
managing push notifications, etc.
Vrije Universiteit Amsterdam
Service workers have a strong control over the data exchanged with
the server
→ the standard mandates to serve them using HTTPS
You can serve contents via HTTPS using the serve-https package
○ http://www.npmjs.com/package/serve-https
You can create your own certificates using Let’sEncrypt
○ http://letsencrypt.org
For additional information on HTTPS for WPA, check out this video
(30 mins):
○ https://youtu.be/e6DUrH56g14?list=PLNYkxOF6rcIAWWNR_Q6eLPhsyx
6VvYjVb
Vrije Universiteit Amsterdam
Purpose: to integrate your app into the device OS
○ icon, name, description of the web app
○ homescreen/launcher integration
○ background color
○ splash screen
○ ...
Included in the HTML code via
<link rel="manifest" href="/manifest.webmanifest">
Vrije Universiteit Amsterdam
{
"name": "MyApplication",
"short_name": "MyApp",
"scope": "./webApp/",
"start_url": "./?launchedFromHome=true",
"orientation": "portrait",
"display": "fullscreen",
"background_color": "#fff",
"description": "A simple application for testing.",
"icons": [{
"src": "images/touch/homescreen48.png",
"sizes": "48x48",
"type": "image/png"
}, ...
}],
"related_applications": [{
"platform": "play",
"url": "https://play.google.com/store/apps/details?id=ID_APP"
}]
}
https://developer.mozilla.org/en-US/docs/Web/Manifest
Vrije Universiteit Amsterdam
Web standard (http://www.w3.org/TR/service-workers)
● offline functionality
● content caching
● push notifications
● performance enhancing
○ eg via data preloading
● background computation
● ...
INTUITION: you can see it as a
programmable network proxy,
allowing you to control how
network requests from your page
are handled
Vrije Universiteit Amsterdam
It is a special case of web worker
→ it runs in a separate thread w.r.t. the main JavaScript thread
It is implemented as a separate JavaScript file
In order to be independent from other workers, each worker script
cannot access:
● the DOM
● the global window object
○ each web worker has its own self global object
Vrije Universiteit Amsterdam
It can control the web page/site it is associated with, intercepting and
modifying network requests
https://goo.gl/SC62O6
Vrije Universiteit Amsterdam
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw-test/sw.js', {scope: '/sw-test/'})
.then(function(reg) {
// registration worked
console.log('Registration succeeded. Scope is ' + reg.scope);
}).catch(function(error) {
// registration failed
console.log('Registration failed with ' + error);
});
}
https://goo.gl/SC62O6
Vrije Universiteit Amsterdam
this.addEventListener('install', function(event) {
event.waitUntil(
caches.open('v1').then(function(cache) {
return cache.addAll([
'/sw-test/',
'/sw-test/index.html',
'/sw-test/style.css',
'/sw-test/app.js',
'/sw-test/image-list.js',
'/sw-test/gallery/snowTroopers.jpg', ...
]);
})
);
});
https://goo.gl/SC62O6
Usually here developers define
static resources to be cached
Vrije Universiteit Amsterdam
this.addEventListener('fetch', function(event) {
event.respondWith(
new Response('<p>I am a static response</p>', {
headers: { 'Content-Type': 'text/html' }
})
);
});
VS
this.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
});
);
});
QUIZ
Describe the high-level behaviour
of these two fragments of code
https://goo.gl/SC62O6
Vrije Universiteit Amsterdam
this.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(resp) {
return resp || fetch(event.request).then(function(response) {
caches.open('v1').then(function(cache) {
cache.put(event.request, response.clone());
});
return response;
});
}).catch(function() {
return caches.match('/sw-test/myLittleVader.jpg');
});
);
});
Other supported events:
● activate
● push
● notificationclick
● sync
● message
https://goo.gl/SC62O6
Vrije Universiteit Amsterdam
HTML5, CSS3, JavaScript
http://developer.mozilla.org/en-US/docs
http://www.w3schools.com
http://eloquentjavascript.net
Progressive web apps
http://github.com/hemanth/awesome-pwa
http://events.withgoogle.com/progressive-web-app-dev-summit/agenda
http://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/

More Related Content

Viewers also liked

The Green Lab - [02 B] Experiment scoping
The Green Lab - [02 B] Experiment scopingThe Green Lab - [02 B] Experiment scoping
The Green Lab - [02 B] Experiment scopingIvano Malavolta
 
The Green Lab - [01 C] Empirical software engineering
The Green Lab - [01 C] Empirical software engineeringThe Green Lab - [01 C] Empirical software engineering
The Green Lab - [01 C] Empirical software engineeringIvano Malavolta
 
The Green Lab - [02 A] The experimental process
The Green Lab - [02 A] The experimental processThe Green Lab - [02 A] The experimental process
The Green Lab - [02 A] The experimental processIvano Malavolta
 
The Green Lab - [03 A] Experiment planning
The Green Lab - [03 A] Experiment planningThe Green Lab - [03 A] Experiment planning
The Green Lab - [03 A] Experiment planningIvano Malavolta
 
The Green Lab - [03 B] Measurement theory basics
The Green Lab - [03 B] Measurement theory basicsThe Green Lab - [03 B] Measurement theory basics
The Green Lab - [03 B] Measurement theory basicsIvano Malavolta
 
The Green Lab - [04 B] [PWA] Experiment setup
The Green Lab - [04 B] [PWA] Experiment setupThe Green Lab - [04 B] [PWA] Experiment setup
The Green Lab - [04 B] [PWA] Experiment setupIvano Malavolta
 
The Green Lab - [04-A] Lab environment and tools
The Green Lab - [04-A] Lab environment and toolsThe Green Lab - [04-A] Lab environment and tools
The Green Lab - [04-A] Lab environment and toolsGiuseppe Procaccianti
 
The Green Lab - [05 A] Experiment design (basics)
The Green Lab - [05 A] Experiment design (basics)The Green Lab - [05 A] Experiment design (basics)
The Green Lab - [05 A] Experiment design (basics)Ivano Malavolta
 
The Green Lab - [05 B] Experiment design (advanced)
The Green Lab - [05 B] Experiment design (advanced)The Green Lab - [05 B] Experiment design (advanced)
The Green Lab - [05 B] Experiment design (advanced)Ivano Malavolta
 
The Green Lab - [07-B] Hypothesis Testing
The Green Lab - [07-B] Hypothesis TestingThe Green Lab - [07-B] Hypothesis Testing
The Green Lab - [07-B] Hypothesis TestingGiuseppe Procaccianti
 
The Green Lab - [07-A] Data Analysis
The Green Lab - [07-A] Data AnalysisThe Green Lab - [07-A] Data Analysis
The Green Lab - [07-A] Data AnalysisGiuseppe Procaccianti
 
The Green Lab - [12-A] Data visualization in R
The Green Lab - [12-A] Data visualization in RThe Green Lab - [12-A] Data visualization in R
The Green Lab - [12-A] Data visualization in RGiuseppe Procaccianti
 
The Green Lab - [11-A] Data Visualization
The Green Lab - [11-A] Data VisualizationThe Green Lab - [11-A] Data Visualization
The Green Lab - [11-A] Data VisualizationGiuseppe Procaccianti
 
The Green Lab - [09 B] Experiment validity
The Green Lab - [09  B] Experiment validityThe Green Lab - [09  B] Experiment validity
The Green Lab - [09 B] Experiment validityIvano Malavolta
 
The Green Lab - [09 A] Statistical tests and effect size
The Green Lab - [09 A] Statistical tests and effect sizeThe Green Lab - [09 A] Statistical tests and effect size
The Green Lab - [09 A] Statistical tests and effect sizeIvano Malavolta
 
Sustainable Software for a Digital Society
Sustainable Software for a Digital SocietySustainable Software for a Digital Society
Sustainable Software for a Digital SocietyPatricia Lago
 
Green Software Lab
Green Software LabGreen Software Lab
Green Software LabGreenLabAtDI
 
Presentation Joost Visser / SIG - what can be green about software- Workshop ...
Presentation Joost Visser / SIG - what can be green about software- Workshop ...Presentation Joost Visser / SIG - what can be green about software- Workshop ...
Presentation Joost Visser / SIG - what can be green about software- Workshop ...Jaak Vlasveld
 
Green-Language programming presentation
Green-Language programming presentationGreen-Language programming presentation
Green-Language programming presentationLorraine Cruz
 

Viewers also liked (20)

The Green Lab - [02 B] Experiment scoping
The Green Lab - [02 B] Experiment scopingThe Green Lab - [02 B] Experiment scoping
The Green Lab - [02 B] Experiment scoping
 
The Green Lab - [01 C] Empirical software engineering
The Green Lab - [01 C] Empirical software engineeringThe Green Lab - [01 C] Empirical software engineering
The Green Lab - [01 C] Empirical software engineering
 
The Green Lab - [02 A] The experimental process
The Green Lab - [02 A] The experimental processThe Green Lab - [02 A] The experimental process
The Green Lab - [02 A] The experimental process
 
The Green Lab - [03 A] Experiment planning
The Green Lab - [03 A] Experiment planningThe Green Lab - [03 A] Experiment planning
The Green Lab - [03 A] Experiment planning
 
The Green Lab - [03 B] Measurement theory basics
The Green Lab - [03 B] Measurement theory basicsThe Green Lab - [03 B] Measurement theory basics
The Green Lab - [03 B] Measurement theory basics
 
The Green Lab - [04 B] [PWA] Experiment setup
The Green Lab - [04 B] [PWA] Experiment setupThe Green Lab - [04 B] [PWA] Experiment setup
The Green Lab - [04 B] [PWA] Experiment setup
 
The Green Lab - [04-A] Lab environment and tools
The Green Lab - [04-A] Lab environment and toolsThe Green Lab - [04-A] Lab environment and tools
The Green Lab - [04-A] Lab environment and tools
 
The Green Lab - [05 A] Experiment design (basics)
The Green Lab - [05 A] Experiment design (basics)The Green Lab - [05 A] Experiment design (basics)
The Green Lab - [05 A] Experiment design (basics)
 
The Green Lab - [05 B] Experiment design (advanced)
The Green Lab - [05 B] Experiment design (advanced)The Green Lab - [05 B] Experiment design (advanced)
The Green Lab - [05 B] Experiment design (advanced)
 
The Green Lab - [07-B] Hypothesis Testing
The Green Lab - [07-B] Hypothesis TestingThe Green Lab - [07-B] Hypothesis Testing
The Green Lab - [07-B] Hypothesis Testing
 
The Green Lab - [07-A] Data Analysis
The Green Lab - [07-A] Data AnalysisThe Green Lab - [07-A] Data Analysis
The Green Lab - [07-A] Data Analysis
 
The Green Lab - [12-A] Data visualization in R
The Green Lab - [12-A] Data visualization in RThe Green Lab - [12-A] Data visualization in R
The Green Lab - [12-A] Data visualization in R
 
The Green Lab - [11-A] Data Visualization
The Green Lab - [11-A] Data VisualizationThe Green Lab - [11-A] Data Visualization
The Green Lab - [11-A] Data Visualization
 
The Green Lab - [09 B] Experiment validity
The Green Lab - [09  B] Experiment validityThe Green Lab - [09  B] Experiment validity
The Green Lab - [09 B] Experiment validity
 
The Green Lab - [09 A] Statistical tests and effect size
The Green Lab - [09 A] Statistical tests and effect sizeThe Green Lab - [09 A] Statistical tests and effect size
The Green Lab - [09 A] Statistical tests and effect size
 
Sustainable Software for a Digital Society
Sustainable Software for a Digital SocietySustainable Software for a Digital Society
Sustainable Software for a Digital Society
 
Green Software Lab
Green Software LabGreen Software Lab
Green Software Lab
 
Green Programming
Green ProgrammingGreen Programming
Green Programming
 
Presentation Joost Visser / SIG - what can be green about software- Workshop ...
Presentation Joost Visser / SIG - what can be green about software- Workshop ...Presentation Joost Visser / SIG - what can be green about software- Workshop ...
Presentation Joost Visser / SIG - what can be green about software- Workshop ...
 
Green-Language programming presentation
Green-Language programming presentationGreen-Language programming presentation
Green-Language programming presentation
 

Similar to The Green Lab - [02 C] [case study] Progressive web apps

Progressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & LearningsProgressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & LearningsJohannes Weber
 
Bruce Lawson Opera Indonesia
Bruce Lawson Opera IndonesiaBruce Lawson Opera Indonesia
Bruce Lawson Opera Indonesiabrucelawson
 
Basic Understanding of Progressive Web Apps
Basic Understanding of Progressive Web AppsBasic Understanding of Progressive Web Apps
Basic Understanding of Progressive Web AppsAnjaliTanpure1
 
Make your PWA feel more like an app
Make your PWA feel more like an appMake your PWA feel more like an app
Make your PWA feel more like an appÖnder Ceylan
 
Building Workflow Applications Through the Web
Building Workflow Applications Through the WebBuilding Workflow Applications Through the Web
Building Workflow Applications Through the WebT. Kim Nguyen
 
Progressive Web Apps 101
Progressive Web Apps 101Progressive Web Apps 101
Progressive Web Apps 101Daniel Black
 
Introduction to silver light
Introduction to silver lightIntroduction to silver light
Introduction to silver lightjayc8586
 
Building native mobile apps using web technologies
Building native mobile apps using web technologiesBuilding native mobile apps using web technologies
Building native mobile apps using web technologiesHjörtur Hilmarsson
 
JavaScript on HP webOS: Enyo and Node.js
JavaScript on HP webOS: Enyo and Node.jsJavaScript on HP webOS: Enyo and Node.js
JavaScript on HP webOS: Enyo and Node.jsBen Combee
 
What Web Developers Need to Know to Develop Windows 8 Apps
What Web Developers Need to Know to Develop Windows 8 AppsWhat Web Developers Need to Know to Develop Windows 8 Apps
What Web Developers Need to Know to Develop Windows 8 AppsDoris Chen
 
openMIC barcamp 11.02.2010
openMIC barcamp 11.02.2010openMIC barcamp 11.02.2010
openMIC barcamp 11.02.2010Patrick Lauke
 
Portfolio - PROGmaatic Developer Network
Portfolio - PROGmaatic Developer NetworkPortfolio - PROGmaatic Developer Network
Portfolio - PROGmaatic Developer NetworkHabib Ullah Bahar
 

Similar to The Green Lab - [02 C] [case study] Progressive web apps (20)

Progressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & LearningsProgressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & Learnings
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
 
Bruce Lawson Opera Indonesia
Bruce Lawson Opera IndonesiaBruce Lawson Opera Indonesia
Bruce Lawson Opera Indonesia
 
WTF R PWAs?
WTF R PWAs?WTF R PWAs?
WTF R PWAs?
 
Basic Understanding of Progressive Web Apps
Basic Understanding of Progressive Web AppsBasic Understanding of Progressive Web Apps
Basic Understanding of Progressive Web Apps
 
Progressive Web Apps - deep dive
Progressive Web Apps - deep diveProgressive Web Apps - deep dive
Progressive Web Apps - deep dive
 
Make your PWA feel more like an app
Make your PWA feel more like an appMake your PWA feel more like an app
Make your PWA feel more like an app
 
Building Workflow Applications Through the Web
Building Workflow Applications Through the WebBuilding Workflow Applications Through the Web
Building Workflow Applications Through the Web
 
Progressive Web Apps 101
Progressive Web Apps 101Progressive Web Apps 101
Progressive Web Apps 101
 
Introduction to silver light
Introduction to silver lightIntroduction to silver light
Introduction to silver light
 
Building native mobile apps using web technologies
Building native mobile apps using web technologiesBuilding native mobile apps using web technologies
Building native mobile apps using web technologies
 
JavaScript on HP webOS: Enyo and Node.js
JavaScript on HP webOS: Enyo and Node.jsJavaScript on HP webOS: Enyo and Node.js
JavaScript on HP webOS: Enyo and Node.js
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
 
Firefox OS Presentation
Firefox OS PresentationFirefox OS Presentation
Firefox OS Presentation
 
Phone gap development, testing, and debugging
Phone gap development, testing, and debuggingPhone gap development, testing, and debugging
Phone gap development, testing, and debugging
 
What Web Developers Need to Know to Develop Windows 8 Apps
What Web Developers Need to Know to Develop Windows 8 AppsWhat Web Developers Need to Know to Develop Windows 8 Apps
What Web Developers Need to Know to Develop Windows 8 Apps
 
mobicon_paper
mobicon_papermobicon_paper
mobicon_paper
 
openMIC barcamp 11.02.2010
openMIC barcamp 11.02.2010openMIC barcamp 11.02.2010
openMIC barcamp 11.02.2010
 
Portfolio - PROGmaatic Developer Network
Portfolio - PROGmaatic Developer NetworkPortfolio - PROGmaatic Developer Network
Portfolio - PROGmaatic Developer Network
 
Phone gap development, testing, and debugging
Phone gap development, testing, and debuggingPhone gap development, testing, and debugging
Phone gap development, testing, and debugging
 

More from Ivano Malavolta

Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...Ivano Malavolta
 
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
The Green Lab - Research cocktail  @Vrije Universiteit Amsterdam (October 2020)The Green Lab - Research cocktail  @Vrije Universiteit Amsterdam (October 2020)
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)Ivano Malavolta
 
Software sustainability and Green IT
Software sustainability and Green ITSoftware sustainability and Green IT
Software sustainability and Green ITIvano Malavolta
 
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Navigation-aware and Personalized Prefetching of Network Requests in Android ...Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Navigation-aware and Personalized Prefetching of Network Requests in Android ...Ivano Malavolta
 
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
How Maintainability Issues of Android Apps Evolve [ICSME 2018]How Maintainability Issues of Android Apps Evolve [ICSME 2018]
How Maintainability Issues of Android Apps Evolve [ICSME 2018]Ivano Malavolta
 
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...Ivano Malavolta
 
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...Ivano Malavolta
 
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...Ivano Malavolta
 
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...Ivano Malavolta
 
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...Ivano Malavolta
 
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...Ivano Malavolta
 
Modeling and abstraction, software development process [Software Design] [Com...
Modeling and abstraction, software development process [Software Design] [Com...Modeling and abstraction, software development process [Software Design] [Com...
Modeling and abstraction, software development process [Software Design] [Com...Ivano Malavolta
 
Reconstructing microservice-based architectures
Reconstructing microservice-based architecturesReconstructing microservice-based architectures
Reconstructing microservice-based architecturesIvano Malavolta
 
[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] AADL - Architecture Analysis and Design Language[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] AADL - Architecture Analysis and Design LanguageIvano Malavolta
 
[2017/2018] Architectural languages
[2017/2018] Architectural languages[2017/2018] Architectural languages
[2017/2018] Architectural languagesIvano Malavolta
 
[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software Architecture[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software ArchitectureIvano Malavolta
 
[2017/2018] RESEARCH in software engineering
[2017/2018] RESEARCH in software engineering[2017/2018] RESEARCH in software engineering
[2017/2018] RESEARCH in software engineeringIvano Malavolta
 
[13 - B] Experiment reporting
[13 - B] Experiment reporting[13 - B] Experiment reporting
[13 - B] Experiment reportingIvano Malavolta
 
[13 - A] Experiment validity
[13 - A] Experiment validity[13 - A] Experiment validity
[13 - A] Experiment validityIvano Malavolta
 

More from Ivano Malavolta (20)

Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
 
The H2020 experience
The H2020 experienceThe H2020 experience
The H2020 experience
 
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
The Green Lab - Research cocktail  @Vrije Universiteit Amsterdam (October 2020)The Green Lab - Research cocktail  @Vrije Universiteit Amsterdam (October 2020)
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
 
Software sustainability and Green IT
Software sustainability and Green ITSoftware sustainability and Green IT
Software sustainability and Green IT
 
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Navigation-aware and Personalized Prefetching of Network Requests in Android ...Navigation-aware and Personalized Prefetching of Network Requests in Android ...
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
 
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
How Maintainability Issues of Android Apps Evolve [ICSME 2018]How Maintainability Issues of Android Apps Evolve [ICSME 2018]
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
 
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
 
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
 
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...
 
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
 
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
 
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
 
Modeling and abstraction, software development process [Software Design] [Com...
Modeling and abstraction, software development process [Software Design] [Com...Modeling and abstraction, software development process [Software Design] [Com...
Modeling and abstraction, software development process [Software Design] [Com...
 
Reconstructing microservice-based architectures
Reconstructing microservice-based architecturesReconstructing microservice-based architectures
Reconstructing microservice-based architectures
 
[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] AADL - Architecture Analysis and Design Language[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] AADL - Architecture Analysis and Design Language
 
[2017/2018] Architectural languages
[2017/2018] Architectural languages[2017/2018] Architectural languages
[2017/2018] Architectural languages
 
[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software Architecture[2017/2018] Introduction to Software Architecture
[2017/2018] Introduction to Software Architecture
 
[2017/2018] RESEARCH in software engineering
[2017/2018] RESEARCH in software engineering[2017/2018] RESEARCH in software engineering
[2017/2018] RESEARCH in software engineering
 
[13 - B] Experiment reporting
[13 - B] Experiment reporting[13 - B] Experiment reporting
[13 - B] Experiment reporting
 
[13 - A] Experiment validity
[13 - A] Experiment validity[13 - A] Experiment validity
[13 - A] Experiment validity
 

Recently uploaded

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

The Green Lab - [02 C] [case study] Progressive web apps

  • 1.
  • 3. Vrije Universiteit Amsterdam A software built with web technologies that is accessible via a mobile browser The browser may be either the standard device browser or an embedded browser (hybrid app)
  • 4. Vrije Universiteit Amsterdam Goal of HTML5 code is to represent the structure and contents of the web page You can see it as a passive container of data to be presented to the user When the user interacts with the display, it triggers events managed by the JavaScript code <!DOCTYPE html> <html> <head> <title>Title</title> </head> <body> … </body> </html>
  • 5. Vrije Universiteit Amsterdam <form action="/computeResult.php" method="post" name="myform"> Enter a value : <input type="text" name="name" /> <input type="email" name="email" /> <input type="number" name="phone" /> <input type="date" name="birthdate" /> <input type="button" value="Send" /> </form>
  • 6. Vrije Universiteit Amsterdam Describes how HTML elements are to be displayed External stylesheets are stored in CSS files with CSS without CSS
  • 7. Vrije Universiteit Amsterdam A couple of examples...
  • 8. Vrije Universiteit Amsterdam JavaScript is the programming code that can be inserted into HTML pages ○ it can react to events in the DOM ○ it can modify the DOM Interpreted language ○ see the eval() function JavaScript HAS NOTHING TO DO WITH Java
  • 10. Vrije Universiteit Amsterdam Every time the app calls the server, it renders a new HTML page e.g., standard PHP websites https://goo.gl/3d1eX6
  • 11. Vrije Universiteit Amsterdamhttps://goo.gl/3d1eX6 ● The application logic is inside a single HTML page ● Data is displayed by updating the HTML DOM in place ○ more fluid w.r.t. a page refresh ● Data is retrieved from the application server using JavaScript
  • 13. Vrije Universiteit Amsterdam ● Web app ○ Acts as a client for user interaction ● Application server ○ Receives requests from the app (usually HTTP messages) ○ Handles business logic ○ Fetches data from the data repo ○ Provides data to apps (with XML or JSON payload) ● Data repository ○ Stores raw data ○ Mainly passive
  • 14. Vrije Universiteit Amsterdam Mobile web apps: ● do not work offline ● no background activities ○ e.g., geofencing ● poor distribution (no app store) ● they are launched via a browser ● poor access to system APIs ○ push notifications, camera, contacts, etc. ● can be unsecure
  • 15. Vrije Universiteit Amsterdam Pros: ● rich user interfaces and/or heavy graphics ● work offline, ● ... Cons: ● FRAGMENTATION ○ development and maintainability costs ● slow iteration pace (stores mediation) ● no indexing by search engines ● no portability ○ an app cannot be deployed on other platforms
  • 17. Vrije Universiteit Amsterdam INTUITION: to combine the best of web and native apps A PWA is a web app, its life starts as a browser tab → no install required, then it becomes an app PWAs can work offline Live in a server → no update distribution delays Support push notifications Live in the home screen of the mobile device Load as top-level, full screen experiences (no browser tabs)
  • 18. Vrije Universiteit Amsterdam 1. The user accesses the website as usual ○ It does not do anything special, but it has already PWA features like TLS, service workers, manifests, and responsive design
  • 19. Vrije Universiteit Amsterdam 1. The user accesses the website as usual ○ It does not do anything special, but it has already PWA features like TLS, service workers, manifests, and responsive design 2. After the 3rd-4th visit, a prompt is shown ○ The prompt is populated from the Manifest https://goo.gl/KIZydg
  • 20. Vrije Universiteit Amsterdam 1. The user accesses the website as usual ○ It does not do anything special, but it has already PWA features like TLS, service workers, manifests, and responsive design 2. After the 3rd-4th visit, a prompt is shown ○ The prompt is populated from the Manifest 3. The user can decide to add the app to the home screen or app launcher https://goo.gl/KIZydg
  • 21. Vrije Universiteit Amsterdam 1. The user accesses the website as usual ○ It does not do anything special, but it has already PWA features like TLS, service workers, manifests, and responsive design 2. After the 3rd-4th visit, a prompt is shown ○ The prompt is populated from the Manifest 3. The user can decide to add the app to the home screen or app launcher 4. When launched from the home screen, the app is top-level, full-screen, and can receive push notifications https://goo.gl/KIZydg
  • 23. Vrije Universiteit Amsterdam A website can be considered a PWA if: 1. it is served over HTTPS ○ this is a requirement for avoiding man-in-the-middle attacks 2. it comes with a Manifest file ○ it declares app name, icon, base URL, etc. 3. it uses service workers ○ a set of APIs for allowing the developer to safely cache and preload data, managing push notifications, etc.
  • 24. Vrije Universiteit Amsterdam Service workers have a strong control over the data exchanged with the server → the standard mandates to serve them using HTTPS You can serve contents via HTTPS using the serve-https package ○ http://www.npmjs.com/package/serve-https You can create your own certificates using Let’sEncrypt ○ http://letsencrypt.org For additional information on HTTPS for WPA, check out this video (30 mins): ○ https://youtu.be/e6DUrH56g14?list=PLNYkxOF6rcIAWWNR_Q6eLPhsyx 6VvYjVb
  • 25. Vrije Universiteit Amsterdam Purpose: to integrate your app into the device OS ○ icon, name, description of the web app ○ homescreen/launcher integration ○ background color ○ splash screen ○ ... Included in the HTML code via <link rel="manifest" href="/manifest.webmanifest">
  • 26. Vrije Universiteit Amsterdam { "name": "MyApplication", "short_name": "MyApp", "scope": "./webApp/", "start_url": "./?launchedFromHome=true", "orientation": "portrait", "display": "fullscreen", "background_color": "#fff", "description": "A simple application for testing.", "icons": [{ "src": "images/touch/homescreen48.png", "sizes": "48x48", "type": "image/png" }, ... }], "related_applications": [{ "platform": "play", "url": "https://play.google.com/store/apps/details?id=ID_APP" }] } https://developer.mozilla.org/en-US/docs/Web/Manifest
  • 27. Vrije Universiteit Amsterdam Web standard (http://www.w3.org/TR/service-workers) ● offline functionality ● content caching ● push notifications ● performance enhancing ○ eg via data preloading ● background computation ● ... INTUITION: you can see it as a programmable network proxy, allowing you to control how network requests from your page are handled
  • 28. Vrije Universiteit Amsterdam It is a special case of web worker → it runs in a separate thread w.r.t. the main JavaScript thread It is implemented as a separate JavaScript file In order to be independent from other workers, each worker script cannot access: ● the DOM ● the global window object ○ each web worker has its own self global object
  • 29. Vrije Universiteit Amsterdam It can control the web page/site it is associated with, intercepting and modifying network requests https://goo.gl/SC62O6
  • 30. Vrije Universiteit Amsterdam if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw-test/sw.js', {scope: '/sw-test/'}) .then(function(reg) { // registration worked console.log('Registration succeeded. Scope is ' + reg.scope); }).catch(function(error) { // registration failed console.log('Registration failed with ' + error); }); } https://goo.gl/SC62O6
  • 31. Vrije Universiteit Amsterdam this.addEventListener('install', function(event) { event.waitUntil( caches.open('v1').then(function(cache) { return cache.addAll([ '/sw-test/', '/sw-test/index.html', '/sw-test/style.css', '/sw-test/app.js', '/sw-test/image-list.js', '/sw-test/gallery/snowTroopers.jpg', ... ]); }) ); }); https://goo.gl/SC62O6 Usually here developers define static resources to be cached
  • 32. Vrije Universiteit Amsterdam this.addEventListener('fetch', function(event) { event.respondWith( new Response('<p>I am a static response</p>', { headers: { 'Content-Type': 'text/html' } }) ); }); VS this.addEventListener('fetch', function(event) { event.respondWith( caches.match(event.request).then(function(response) { return response || fetch(event.request); }); ); }); QUIZ Describe the high-level behaviour of these two fragments of code https://goo.gl/SC62O6
  • 33. Vrije Universiteit Amsterdam this.addEventListener('fetch', function(event) { event.respondWith( caches.match(event.request).then(function(resp) { return resp || fetch(event.request).then(function(response) { caches.open('v1').then(function(cache) { cache.put(event.request, response.clone()); }); return response; }); }).catch(function() { return caches.match('/sw-test/myLittleVader.jpg'); }); ); }); Other supported events: ● activate ● push ● notificationclick ● sync ● message https://goo.gl/SC62O6
  • 34. Vrije Universiteit Amsterdam HTML5, CSS3, JavaScript http://developer.mozilla.org/en-US/docs http://www.w3schools.com http://eloquentjavascript.net Progressive web apps http://github.com/hemanth/awesome-pwa http://events.withgoogle.com/progressive-web-app-dev-summit/agenda http://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/