SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
BUILDING
WEBAPP FOR
MOBILE
Trần Lê Duy Tiên
A Proud Clicker @ VNG Corp.
http://facebook.com/leduytien
http://zini.vn/leduytien
A short summary
of WEBAPPorigin
A SHORTHISTORYOF WEBAPP
• WebApp got first wide-spreaded
attention after the introduction of the
first generation iPhone, thanks to the
fact that Apple didn’t allow native
app development at the time.
• After the iPhone, Palm introduced
WebOS for their smartphones,
designed with the dream of a webapp
platform.
• Google recently introduced Google
Chrome OS with only webapp running
on it.
WHATISWEBAPP & WHY?
WebApp
• “Web”: it is built using only web technologies such
as HTML, Javascript and CSS
• “App”: it should behave like an “app”, all
interactions occur within the app (there is no
page linking from the user point of view) & be
able to work without Internet.
Why is webapp?
• Webapp getting popular in the mobile era as it is
the only solution for the dream of developers to
only have to write once and run it anywhere.
Thestate of webapp
• Facebook abandoned their webapp-based
application and switched to native app.
• Palm’s WebOS after sold to HP is dead
• Google is experimenting with webapp on their
Chrome browser & Chrome OS, but so far it’s still
unclear.
WHY?
• Even on the latest version of iOS, webapp still
can’t match what native app can do both in term
of performance and feature
• Users don’t get it.
zing newswebapp
EXPERIMENTS
theFIRST VERSION
The first version of Zing News Webapp (no longer
available). Viewers are automatically redirected to
this app on browser when they visit Zing News
theSECOND(CURRENT)VERSION
On iOS devices, browse http://news.zing.vn will
automatically redirect you to this webapp. On Android
devices, point your browser to http://touch.news.zing.vn
ThingsLEARNED
• When visit a webpage from browser, users
expect to see the web as they known. Any
different in the way the web respond lead
to confusion.
• Users never see the webapp as an app if it
open in browser. To them it’s just a website
behaving different & strange.
• Don’t try make a website behave like an
app. If you build webapp, it is meant to be
install/launch like an app.
THETHIRD ATTEMPT
Would be released together with Zing News version
3 introduced in previous presentation.
BUILDING A WEBAPP
Thingsyouneedto learn
Assume you already “master” HTML & CSS &
Javascript, this presentation will just go over
some major implementation points to build
webapp:
• How to enable webapp capability in iOS
• Basic structure of a webapp
• How to download resources to local device
• How to use web storage API to cache data to
local database
• Tips building webapp
Enable webapp capability FOR WEBPAGE
<head>
<meta name="viewport" content="width=device-width,initial-
scale=1, user-scalable=no">
<link rel="apple-touch-icon" href="touch-icon.png" />
<link rel="apple-touch-icon" sizes="72x72" href="touch-
icon-ipad.png" />
<link rel="apple-touch-icon" sizes="114x114" href="touch-
icon-rentina.png" />
<link href="splash-screen-640x1096.jpg" rel="apple-touch-
startup-image" media="(device-height: 568px)">
<link href="splash-screen-640.jpg" rel="apple-touch-
startup-image" sizes="640x920" media="(device-height:
480px)">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style"
content="black">
CODEStructureOF YOURWEBAPP
It’s a single web page.
There is no “linking” in
app, all data will load
using ajax & displayed.
Your single HTML file
should only include
basic HTML for screen
layers that will be filled
with content later.
Change z-index value
to make a layer active
<html manifest="cache.manifest">
<head>
(include normal js/css
resources)
</head>
<body>
<div id=“latest”>
</div>
<div id=“featured”>
</div>
<div id=“article”>
</div>
<div id=“category”>
</div>
<div id=“popup”></div>
</body>
</html>
MANIFEST– SAVEYOURSITES
You can still run an
app without Internet
connection. A
webapp therefore
should be able to at
least open offline.
Use cache.manifest
file to tell browser to
download your app
resources to local
device and use them
for later access.
CACHE MANIFEST
# rev 1.00
CACHE:
js/jquery.min.js
css/styles.css
img/icons.png
NETWORK:
http://www.sites/img_folder/
http://www.sites/data_folder/
http://www.google-analytics.com/
FALLBACK:
/ offline.html
http://connect.facebook.com/ js/offline.js
UNDERSTANDHOWMANIFESTWORK
The first time you visit a site with manifest, the
browser just show the page and in the
background download the resources
The next time you visit the site, the browser use
the offline version it downloaded last time. In
the background, it check the manifest for any
changes. If yes, it redownload all resources
again.
User will always used the version older than the
current one until he/she relaunch the web.
CREATE AN “INSTALLATION” MECHANISM
Create a middle step to check for updates
all app resources before redirect user to the
main app.
Install.html App.htmlUSER
INSTALLATIONMECHANISM
window.addEventListener('load', function(e) {
var appCache = window.applicationCache;
// no update
appCache.addEventListener('noupdate', function(){
window.location.href = appHome;
}, false);
// all resource had been cached
appCache.addEventListener('cached', function(){
window.location.href = appHome;
}, false);
// if there is updates and resources had been downloaded
appCache.addEventListener('updateready', function(e) {
if (appCache.status == appCache.UPDATEREADY) {
window.applicationCache.swapCache();
}
}, false);
// if is downloading, update the progress bar
appCache.addEventListener('downloading', function(){
appCache.addEventListener('progress', function(){ … });
})
});
Usinglocaldb to cachedata
What if user open your webapp without Internet
connection? Your app should still be able to display
data the last time it had.
Two types of storage available in HTML5
• window.localStorage – which save data until you
delete them (or out of space limit)
• window.sessionStorage – only save data in the
same session
Both have disk space limit, with each domain have
about 5MB for database.
USINGLOCALSTORAGE
Check if browser support:
'sessionStorage' in window && window['sessionStorage'] !== null
'localStorage' in window && window['localStorage'] !== null
Save data
window.localStorage.setItem(key, data);
window.sessionStorage.setItem(key, data);
Retrieve data
window.localStorage.getItem(key); // always return as String
window.sessionStorage.getItem(key); // always return as String
Clear database
window.localStorage.clear();
window.sessionStorage.clear();
CACHINGDATAWITH LOCALSTORAGE
$.ajax({
url:url,
dataType: "text”
}).done(function(data) {
// save the data
if (local DB support)
window.localStorage.setItem(url,data);
// do other things with data
}).fail(function() {
if (window.localStorage.getItem(url) !== null)
// use the cache data
else
// inform user there is no data available
});
TIPS WHENBUILDINGWEBAPP
• Make webapp fullscreen on iPhone 5:
if (window.screen.height==568) { // iPhone 4"
document.querySelector("meta[name=viewport]").content=
"width=320.1";
}
• Set cache expiration for manifest file immediately.
Remove it during development process.
• Don’t use any mobile js framework (jQuery core is
ok to reduce coding time)
• For HTML element, assign ID attribute whenever
possible so that you can get to it faster.
• Remember to use setTimeOut – a few hundred
milliseconds delay will help smoother the
experience.
TIPS WHENBUILDINGWEBAPP
• Make your app responsive & fast. For all UI
interaction event, always update the
interface first. Small trick might help.
• Make sure there only max two concurrent ajax
calls at any moment
$.xhrPool = [];
$.ajaxSetup({
beforeSend: function(jqXHR) {
$.xhrPool.push(jqXHR);
},
complete: function(jqXHR) {
var index = $.xhrPool.indexOf(jqXHR);
if (index > -1) $.xhrPool.splice(index, 1);
}
});
TIPS WHENBUILDINGWEBAPP
• Use CSS animation insteads of js animation
whenever possible.
• There is jQuery plugin that automatically convert .animate()
function to css base animation.
• CSS animation ready to use: http://daneden.me/animate/
• Prevent web scrolling effect:
document.addEventListener('touchmove', function (e) {
e.preventDefault();
}, false);
• Enable 3d hardware on selected elements will
help eliminate UI “flicker”, but be careful or your
app will crash
-webkit-transform:translate3d(0,0,0);
Building WebApp with HTML5

Mais conteúdo relacionado

Mais procurados

A year with progressive web apps! #DevConMU
A year with progressive web apps! #DevConMUA year with progressive web apps! #DevConMU
A year with progressive web apps! #DevConMUAntonio Peric-Mazar
 
Web Accessibility Gone Wild (Now Even MORE Wilder!)
Web Accessibility Gone Wild (Now Even MORE Wilder!)Web Accessibility Gone Wild (Now Even MORE Wilder!)
Web Accessibility Gone Wild (Now Even MORE Wilder!)Jared Smith
 
Building Mobile Applications with Ionic
Building Mobile Applications with IonicBuilding Mobile Applications with Ionic
Building Mobile Applications with IonicMorris Singer
 
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
 
Joomlatools Platform v1.0
Joomlatools Platform v1.0Joomlatools Platform v1.0
Joomlatools Platform v1.0Joomlatools
 
FEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing MojitoFEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing MojitoCaridy Patino
 
Bruce lawson-over-the-air
Bruce lawson-over-the-airBruce lawson-over-the-air
Bruce lawson-over-the-airbrucelawson
 
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...Robert Nyman
 
RESS: An Evolution of Responsive Web Design
RESS: An Evolution of Responsive Web DesignRESS: An Evolution of Responsive Web Design
RESS: An Evolution of Responsive Web DesignDave Olsen
 
Service workers are your best friends
Service workers are your best friendsService workers are your best friends
Service workers are your best friendsAntonio Peric-Mazar
 
HTML5 and friends - Institutional Web Management Workshop 2010
HTML5 and friends - Institutional Web Management Workshop 2010HTML5 and friends - Institutional Web Management Workshop 2010
HTML5 and friends - Institutional Web Management Workshop 2010Patrick Lauke
 
Bruce Lawson, Web Development 2.0, SparkUp! Poznan Poland
Bruce Lawson, Web Development 2.0, SparkUp! Poznan PolandBruce Lawson, Web Development 2.0, SparkUp! Poznan Poland
Bruce Lawson, Web Development 2.0, SparkUp! Poznan Polandbrucelawson
 
Why Open Web Standards are cool and will save the world. Or the Web, at least.
Why Open Web Standards are cool and will save the world. Or the Web, at least.Why Open Web Standards are cool and will save the world. Or the Web, at least.
Why Open Web Standards are cool and will save the world. Or the Web, at least.brucelawson
 
Keyboard and Interaction Accessibility Techniques
Keyboard and Interaction Accessibility TechniquesKeyboard and Interaction Accessibility Techniques
Keyboard and Interaction Accessibility TechniquesJared Smith
 
Makingweb: Great front end performance starts on the server.
Makingweb: Great front end performance starts on the server.Makingweb: Great front end performance starts on the server.
Makingweb: Great front end performance starts on the server.Jon Arne Sæterås
 
One code Web, iOS, Android
One code Web, iOS, AndroidOne code Web, iOS, Android
One code Web, iOS, AndroidArtem Marchenko
 

Mais procurados (20)

A year with progressive web apps! #DevConMU
A year with progressive web apps! #DevConMUA year with progressive web apps! #DevConMU
A year with progressive web apps! #DevConMU
 
Joomla 101
Joomla 101Joomla 101
Joomla 101
 
Web Accessibility Gone Wild (Now Even MORE Wilder!)
Web Accessibility Gone Wild (Now Even MORE Wilder!)Web Accessibility Gone Wild (Now Even MORE Wilder!)
Web Accessibility Gone Wild (Now Even MORE Wilder!)
 
Building Mobile Applications with Ionic
Building Mobile Applications with IonicBuilding Mobile Applications with Ionic
Building Mobile Applications with Ionic
 
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
 
Joomlatools Platform v1.0
Joomlatools Platform v1.0Joomlatools Platform v1.0
Joomlatools Platform v1.0
 
FEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing MojitoFEDM Meetup: Introducing Mojito
FEDM Meetup: Introducing Mojito
 
Bruce lawson-over-the-air
Bruce lawson-over-the-airBruce lawson-over-the-air
Bruce lawson-over-the-air
 
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
 
RESS: An Evolution of Responsive Web Design
RESS: An Evolution of Responsive Web DesignRESS: An Evolution of Responsive Web Design
RESS: An Evolution of Responsive Web Design
 
Progressive Web Apps are here!
Progressive Web Apps are here!Progressive Web Apps are here!
Progressive Web Apps are here!
 
Service workers are your best friends
Service workers are your best friendsService workers are your best friends
Service workers are your best friends
 
Getting Your Hooks into Cordova
Getting Your Hooks into CordovaGetting Your Hooks into Cordova
Getting Your Hooks into Cordova
 
HTML5 and friends - Institutional Web Management Workshop 2010
HTML5 and friends - Institutional Web Management Workshop 2010HTML5 and friends - Institutional Web Management Workshop 2010
HTML5 and friends - Institutional Web Management Workshop 2010
 
Bruce Lawson, Web Development 2.0, SparkUp! Poznan Poland
Bruce Lawson, Web Development 2.0, SparkUp! Poznan PolandBruce Lawson, Web Development 2.0, SparkUp! Poznan Poland
Bruce Lawson, Web Development 2.0, SparkUp! Poznan Poland
 
PWA
PWAPWA
PWA
 
Why Open Web Standards are cool and will save the world. Or the Web, at least.
Why Open Web Standards are cool and will save the world. Or the Web, at least.Why Open Web Standards are cool and will save the world. Or the Web, at least.
Why Open Web Standards are cool and will save the world. Or the Web, at least.
 
Keyboard and Interaction Accessibility Techniques
Keyboard and Interaction Accessibility TechniquesKeyboard and Interaction Accessibility Techniques
Keyboard and Interaction Accessibility Techniques
 
Makingweb: Great front end performance starts on the server.
Makingweb: Great front end performance starts on the server.Makingweb: Great front end performance starts on the server.
Makingweb: Great front end performance starts on the server.
 
One code Web, iOS, Android
One code Web, iOS, AndroidOne code Web, iOS, Android
One code Web, iOS, Android
 

Semelhante a Building WebApp with HTML5

Building great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to knowBuilding great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to knowshwetank
 
Creating Rajanikant Powered Site
Creating Rajanikant Powered SiteCreating Rajanikant Powered Site
Creating Rajanikant Powered Sitemarkandey
 
Skill Session - Web Multi Device
Skill Session - Web Multi DeviceSkill Session - Web Multi Device
Skill Session - Web Multi Devicefilirom1
 
Responsive web design & mobile web development - a technical and business app...
Responsive web design & mobile web development - a technical and business app...Responsive web design & mobile web development - a technical and business app...
Responsive web design & mobile web development - a technical and business app...Atos_Worldline
 
Eye candy for your iPhone
Eye candy for your iPhoneEye candy for your iPhone
Eye candy for your iPhoneBrian Shim
 
Taking Web Applications Offline
Taking Web Applications OfflineTaking Web Applications Offline
Taking Web Applications OfflineMatt Casto
 
Offline of web applications
Offline of web applicationsOffline of web applications
Offline of web applicationsFDConf
 
Offline for web - Frontend Dev Conf Minsk 2014
Offline for web - Frontend Dev Conf Minsk 2014Offline for web - Frontend Dev Conf Minsk 2014
Offline for web - Frontend Dev Conf Minsk 2014Jan Jongboom
 
HTML5: the new frontier of the web
HTML5: the new frontier of the webHTML5: the new frontier of the web
HTML5: the new frontier of the webIvano Malavolta
 
Html5 and beyond the next generation of mobile web applications - Touch Tou...
Html5 and beyond   the next generation of mobile web applications - Touch Tou...Html5 and beyond   the next generation of mobile web applications - Touch Tou...
Html5 and beyond the next generation of mobile web applications - Touch Tou...RIA RUI Society
 
Introduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDKIntroduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDKBrendan Lim
 
Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...IT Event
 
Develop an app for Windows 8 using HTML5
Develop an app for Windows 8 using HTML5Develop an app for Windows 8 using HTML5
Develop an app for Windows 8 using HTML5Soumow Dollon
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and moreYan Shi
 
Web app and more
Web app and moreWeb app and more
Web app and morefaming su
 
Building jQuery Mobile Web Apps
Building jQuery Mobile Web AppsBuilding jQuery Mobile Web Apps
Building jQuery Mobile Web AppsOperation Mobile
 
Alex Corbi building a 100 % Open Source based Open Data Platform
Alex Corbi building a 100 % Open Source based Open Data PlatformAlex Corbi building a 100 % Open Source based Open Data Platform
Alex Corbi building a 100 % Open Source based Open Data PlatformAlex Corbi
 
Primefaces mobile users_guide_0_9
Primefaces mobile users_guide_0_9Primefaces mobile users_guide_0_9
Primefaces mobile users_guide_0_9ednilsoncampos
 

Semelhante a Building WebApp with HTML5 (20)

Building great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to knowBuilding great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to know
 
Creating Rajanikant Powered Site
Creating Rajanikant Powered SiteCreating Rajanikant Powered Site
Creating Rajanikant Powered Site
 
Skill Session - Web Multi Device
Skill Session - Web Multi DeviceSkill Session - Web Multi Device
Skill Session - Web Multi Device
 
Responsive web design & mobile web development - a technical and business app...
Responsive web design & mobile web development - a technical and business app...Responsive web design & mobile web development - a technical and business app...
Responsive web design & mobile web development - a technical and business app...
 
Eye candy for your iPhone
Eye candy for your iPhoneEye candy for your iPhone
Eye candy for your iPhone
 
Taking Web Applications Offline
Taking Web Applications OfflineTaking Web Applications Offline
Taking Web Applications Offline
 
Offline of web applications
Offline of web applicationsOffline of web applications
Offline of web applications
 
Offline for web - Frontend Dev Conf Minsk 2014
Offline for web - Frontend Dev Conf Minsk 2014Offline for web - Frontend Dev Conf Minsk 2014
Offline for web - Frontend Dev Conf Minsk 2014
 
HTML5: the new frontier of the web
HTML5: the new frontier of the webHTML5: the new frontier of the web
HTML5: the new frontier of the web
 
Always on! ... or not?
Always on! ... or not?Always on! ... or not?
Always on! ... or not?
 
Html5 and beyond the next generation of mobile web applications - Touch Tou...
Html5 and beyond   the next generation of mobile web applications - Touch Tou...Html5 and beyond   the next generation of mobile web applications - Touch Tou...
Html5 and beyond the next generation of mobile web applications - Touch Tou...
 
Introduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDKIntroduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDK
 
Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...
 
Develop an app for Windows 8 using HTML5
Develop an app for Windows 8 using HTML5Develop an app for Windows 8 using HTML5
Develop an app for Windows 8 using HTML5
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Web app and more
Web app and moreWeb app and more
Web app and more
 
Building jQuery Mobile Web Apps
Building jQuery Mobile Web AppsBuilding jQuery Mobile Web Apps
Building jQuery Mobile Web Apps
 
Mobile native-hacks
Mobile native-hacksMobile native-hacks
Mobile native-hacks
 
Alex Corbi building a 100 % Open Source based Open Data Platform
Alex Corbi building a 100 % Open Source based Open Data PlatformAlex Corbi building a 100 % Open Source based Open Data Platform
Alex Corbi building a 100 % Open Source based Open Data Platform
 
Primefaces mobile users_guide_0_9
Primefaces mobile users_guide_0_9Primefaces mobile users_guide_0_9
Primefaces mobile users_guide_0_9
 

Último

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Último (20)

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Building WebApp with HTML5

  • 2. Trần Lê Duy Tiên A Proud Clicker @ VNG Corp. http://facebook.com/leduytien http://zini.vn/leduytien
  • 3. A short summary of WEBAPPorigin
  • 4. A SHORTHISTORYOF WEBAPP • WebApp got first wide-spreaded attention after the introduction of the first generation iPhone, thanks to the fact that Apple didn’t allow native app development at the time. • After the iPhone, Palm introduced WebOS for their smartphones, designed with the dream of a webapp platform. • Google recently introduced Google Chrome OS with only webapp running on it.
  • 5. WHATISWEBAPP & WHY? WebApp • “Web”: it is built using only web technologies such as HTML, Javascript and CSS • “App”: it should behave like an “app”, all interactions occur within the app (there is no page linking from the user point of view) & be able to work without Internet. Why is webapp? • Webapp getting popular in the mobile era as it is the only solution for the dream of developers to only have to write once and run it anywhere.
  • 6. Thestate of webapp • Facebook abandoned their webapp-based application and switched to native app. • Palm’s WebOS after sold to HP is dead • Google is experimenting with webapp on their Chrome browser & Chrome OS, but so far it’s still unclear. WHY? • Even on the latest version of iOS, webapp still can’t match what native app can do both in term of performance and feature • Users don’t get it.
  • 8. theFIRST VERSION The first version of Zing News Webapp (no longer available). Viewers are automatically redirected to this app on browser when they visit Zing News
  • 9. theSECOND(CURRENT)VERSION On iOS devices, browse http://news.zing.vn will automatically redirect you to this webapp. On Android devices, point your browser to http://touch.news.zing.vn
  • 10. ThingsLEARNED • When visit a webpage from browser, users expect to see the web as they known. Any different in the way the web respond lead to confusion. • Users never see the webapp as an app if it open in browser. To them it’s just a website behaving different & strange. • Don’t try make a website behave like an app. If you build webapp, it is meant to be install/launch like an app.
  • 11. THETHIRD ATTEMPT Would be released together with Zing News version 3 introduced in previous presentation.
  • 13. Thingsyouneedto learn Assume you already “master” HTML & CSS & Javascript, this presentation will just go over some major implementation points to build webapp: • How to enable webapp capability in iOS • Basic structure of a webapp • How to download resources to local device • How to use web storage API to cache data to local database • Tips building webapp
  • 14. Enable webapp capability FOR WEBPAGE <head> <meta name="viewport" content="width=device-width,initial- scale=1, user-scalable=no"> <link rel="apple-touch-icon" href="touch-icon.png" /> <link rel="apple-touch-icon" sizes="72x72" href="touch- icon-ipad.png" /> <link rel="apple-touch-icon" sizes="114x114" href="touch- icon-rentina.png" /> <link href="splash-screen-640x1096.jpg" rel="apple-touch- startup-image" media="(device-height: 568px)"> <link href="splash-screen-640.jpg" rel="apple-touch- startup-image" sizes="640x920" media="(device-height: 480px)"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black">
  • 15. CODEStructureOF YOURWEBAPP It’s a single web page. There is no “linking” in app, all data will load using ajax & displayed. Your single HTML file should only include basic HTML for screen layers that will be filled with content later. Change z-index value to make a layer active <html manifest="cache.manifest"> <head> (include normal js/css resources) </head> <body> <div id=“latest”> </div> <div id=“featured”> </div> <div id=“article”> </div> <div id=“category”> </div> <div id=“popup”></div> </body> </html>
  • 16. MANIFEST– SAVEYOURSITES You can still run an app without Internet connection. A webapp therefore should be able to at least open offline. Use cache.manifest file to tell browser to download your app resources to local device and use them for later access. CACHE MANIFEST # rev 1.00 CACHE: js/jquery.min.js css/styles.css img/icons.png NETWORK: http://www.sites/img_folder/ http://www.sites/data_folder/ http://www.google-analytics.com/ FALLBACK: / offline.html http://connect.facebook.com/ js/offline.js
  • 17. UNDERSTANDHOWMANIFESTWORK The first time you visit a site with manifest, the browser just show the page and in the background download the resources The next time you visit the site, the browser use the offline version it downloaded last time. In the background, it check the manifest for any changes. If yes, it redownload all resources again. User will always used the version older than the current one until he/she relaunch the web.
  • 18. CREATE AN “INSTALLATION” MECHANISM Create a middle step to check for updates all app resources before redirect user to the main app. Install.html App.htmlUSER
  • 19. INSTALLATIONMECHANISM window.addEventListener('load', function(e) { var appCache = window.applicationCache; // no update appCache.addEventListener('noupdate', function(){ window.location.href = appHome; }, false); // all resource had been cached appCache.addEventListener('cached', function(){ window.location.href = appHome; }, false); // if there is updates and resources had been downloaded appCache.addEventListener('updateready', function(e) { if (appCache.status == appCache.UPDATEREADY) { window.applicationCache.swapCache(); } }, false); // if is downloading, update the progress bar appCache.addEventListener('downloading', function(){ appCache.addEventListener('progress', function(){ … }); }) });
  • 20. Usinglocaldb to cachedata What if user open your webapp without Internet connection? Your app should still be able to display data the last time it had. Two types of storage available in HTML5 • window.localStorage – which save data until you delete them (or out of space limit) • window.sessionStorage – only save data in the same session Both have disk space limit, with each domain have about 5MB for database.
  • 21. USINGLOCALSTORAGE Check if browser support: 'sessionStorage' in window && window['sessionStorage'] !== null 'localStorage' in window && window['localStorage'] !== null Save data window.localStorage.setItem(key, data); window.sessionStorage.setItem(key, data); Retrieve data window.localStorage.getItem(key); // always return as String window.sessionStorage.getItem(key); // always return as String Clear database window.localStorage.clear(); window.sessionStorage.clear();
  • 22. CACHINGDATAWITH LOCALSTORAGE $.ajax({ url:url, dataType: "text” }).done(function(data) { // save the data if (local DB support) window.localStorage.setItem(url,data); // do other things with data }).fail(function() { if (window.localStorage.getItem(url) !== null) // use the cache data else // inform user there is no data available });
  • 23. TIPS WHENBUILDINGWEBAPP • Make webapp fullscreen on iPhone 5: if (window.screen.height==568) { // iPhone 4" document.querySelector("meta[name=viewport]").content= "width=320.1"; } • Set cache expiration for manifest file immediately. Remove it during development process. • Don’t use any mobile js framework (jQuery core is ok to reduce coding time) • For HTML element, assign ID attribute whenever possible so that you can get to it faster. • Remember to use setTimeOut – a few hundred milliseconds delay will help smoother the experience.
  • 24. TIPS WHENBUILDINGWEBAPP • Make your app responsive & fast. For all UI interaction event, always update the interface first. Small trick might help. • Make sure there only max two concurrent ajax calls at any moment $.xhrPool = []; $.ajaxSetup({ beforeSend: function(jqXHR) { $.xhrPool.push(jqXHR); }, complete: function(jqXHR) { var index = $.xhrPool.indexOf(jqXHR); if (index > -1) $.xhrPool.splice(index, 1); } });
  • 25. TIPS WHENBUILDINGWEBAPP • Use CSS animation insteads of js animation whenever possible. • There is jQuery plugin that automatically convert .animate() function to css base animation. • CSS animation ready to use: http://daneden.me/animate/ • Prevent web scrolling effect: document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false); • Enable 3d hardware on selected elements will help eliminate UI “flicker”, but be careful or your app will crash -webkit-transform:translate3d(0,0,0);