OSCAL 2017, Alban Xhaferllari
B.Sc. & M.Sc. in Computer Science
Full Stack Dev, Italy
Full Stack Dev, Ireland
Senior Front End Dev, Dublin Ireland
Author of Real Uploader
ngular Developer
JS since 2005
Born in Corovodë
www.vlora-guide.com
www.saranda-guide.com
There is a rising threat of single-vendor solutions
Close source
<applet>
<script type="text/vbscript">
msgbox "Vbscript"
</script>
VS
Mozilla, Opera Join Forces For New W3C Proposal
http://www.internetnews.com/bus-news/article.php/3361141
2004
2005
2009
2010
2016
looks better at http://www.evolutionoftheweb.com
<video controls>
<source src="devstories.webm"
type='video/webm;codecs="vp8, vorbis"'/>
<source src="devstories.mp4"
type='video/mp4;codecs="avc1.42E01E, mp4a.40.2"'/>
</video>
var myWorker = new Worker('worker.js');
var connection = new WebSocket('ws://html5rocks.websocket.org/echo', ['soap', 'xmpp']);
navigator.geolocation.getCurrentPosition(function(position) {
do_something(position.coords.latitude, position.coords.longitude);
});
"There's a new existential threat... It's not Flash and Silverlight – it's native apps, [which are] feeding off the web, and arguably killing the web." – Bruce Lawson (2016)
Progressive Web Apps are user experiences that have the reach of the web, and are:
*from Google
40% of the users abandon a website that takes more than 3 seconds to load
Internet is fast
We have powerful devices
Unlimited space
We build the internet and it's based on rough consensus and running code
Browser developers are not better at building websites than web developers
Offline First
if (navigator.serviceWorker) {
navigator.serviceWorker.register('/sw.js');
}
In your web page:
Support
Under development
Under consideration
self.addEventListener('fetch', function(){
debugger;
});
self.addEventListener('fetch', event => {
event.respondWith(
new Response('Hello');
);
});
self.addEventListener('fetch', event => {
const url = new URL(event.request.url);
if (url.pathname.endsWith('.jpg')) {
event.respondWith(
fetch('ncage.jpg');
);
}
});
Handling offline
//Put offline.html page into cache on the first load
self.addEventListener('install', function(event) {
var offlineRequest = new Request('offline.html');
event.waitUntil(
fetch(offlineRequest).then(function(response) {
return caches.open('offline').then(function(cache) {
console.log('[oninstall] Cached offline page', response.url);
return cache.put(offlineRequest, response);
});
})
);
});
self.addEventListener('fetch', event => {
var request = event.request;
if (request.method === 'GET' && request.headers.get(‘accept’).includes('text/html')) {
event.respondWith(
fetch(request).catch(function(error) {
console.error('[onfetch] Failed. Serving cached offline fallback ' + error);
return caches.open('offline').then(function(cache) {
return cache.match('offline.html');
});
})
);
}
});
Jake Archibald: Chrome Dev
Edge Dev
IndexedDB
// Register your service worker:
navigator.serviceWorker.register('/sw.js');
// Then later, request a one-off sync:
navigator.serviceWorker.ready.then(function(swRegistration) {
return swRegistration.sync.register('myFirstSync');
});
App Manifest file
{
"name": "Telegram",
"description": "Telegram Web App.\nMore info & source code here: https://github.com/zhukov/webogram",
"short_name": "Telegram",
"display": "standalone",
"theme_color": "#497495",
"gcm_sender_id": "122867383838",
"start_url": "./?utm_source=web_app_manifest",
"scope": "/",
"background_color": "#fff",
"icons": [
{
"src": "img/icons/icon16.png",
"type": "image/png",
"sizes": "16x16"
}//...
],
"related_applications": [
{
"platform": "play",
"id": "org.telegram.messenger",
"url": "https://telegram.org/dl/android?ref=webmanifest"
},
{
"platform": "itunes",
"url": "https://telegram.org/dl/ios?ref=webmanifest"
}
]
}
<link rel="manifest" href="/manifest.json">
Link in your HTML <head>
Push Notification
Use WebWorkers for processing
navigator.getBattery()
WebSockets
Fetch Api
Web is progressing
Browser support is progressing
You app is progressing
https://www.pwastats.com/
Telegram Web is a Progressive Web App
https://github.com/albanx/oscal-17-demo
SW 8.41s
No SW 7.7s
First load
Connection 3G
https://github.com/albanx/oscal-17-demo
SW 4.32s
No SW 7.7s
Second load
Connection 3G
https://github.com/albanx/oscal-17-demo
SW 1.38s
--
No Connection
Third load
https://github.com/albanx/oscal-17-demo
No Connection
Perform a search
Custom response
https://github.com/albanx/oscal-17-demo
https://www.pwastats.com/
https://github.com/GoogleChrome/samples/tree/gh-pages/service-worker
https://www.youtube.com/watch?v=cmGr0RszHc8
http://www.pwabuilder.com
https://github.com/albanx
albanx@gmail.com
@albanx0
Ireland is hiring