SlideShare a Scribd company logo
1 of 50
Download to read offline
Gran Sasso Science Institute
+ Università degli Studi dell’Aquila
Ivano Malavolta
Fast mobile web apps
Intro
You will leave this presentation with...

an understanding of what makes a mobile web app slow
techniques to improve the performance of your mobile web apps


In any case, step zero to success is to be technologically ready, 
for example many people tend to underestimate JavaScript, don't!
http://eloquentjavascript.net
Roadmap
•  Use the DOM efficiently
•  Master events
•  Be smart with the network 
•  Take care of memory issues
•  Take advantage of CSS3 features

The best practices and advices in this presentation are
implemented in a generic app template available here:

https://github.com/iivanoo/cordovaboilerplate
Always “cache” elements from the DOM
every time you do $(‘id’) the browser must parse the whole DOM
Minimize DOM reflows
A reflow is triggered every time the content of the DOM changes, DOM elements are resized, CSS
positioning/padding/margins are changed, etc.

•  Use CSS transforms, transitions and animation
•  Use fixed widths and heights (when possible)
•  Avoid changing elements of the DOM
They change the appearance of the DOM, but do not
trigger a reflow op
Reflow:
the browser process for calculating positions and geometries
for HTML DOM elements
Keep your DOM slim
Reflow operations are much heavier when

•  the number of nodes in the DOM is large
•  there are deeply nested DOM nodes

Document
 HTML
 Body
Element
Element
Element
Element
Element
Element
Element
Element
Element
Navigate the DOM with built-in methods
Avoid to continuously query the DOM if you can reach specific DOM nodes using its built-in methods
Examples of built-in JS properties for navigation
element.parentNode — returns the node containing the element in the DOM
element.childNodes; — returns all the nested nodes of the element in the DOM
element.firstChild — retrieves the first nested node of the element in the DOM
element.lastChild — retrieves the last nested node of the element in the DOM
element.nextSibling — returns the node immediately following the element in the DOM
element.previousSibling — returns the node immediately preceding the element in the DOM
Avoid to interact with the DOM too often 
Every time you append a node in the DOM, a reflow operation is triggered
Prefer built-in JavaScript methods
Under the lines, all JS frameworks end up in calling standard JavaScript methods 
à 
when it’s possible, prefer JavaScript built-in methods to pass through a framework





Many frameworks contain a lot of workarounds and fallbacks for older
browsers that we are not targeting (e.g., Internet Explorer 7)
Examples of built-in JS methods
element.innerHTML; — returns the contents of the DOM node
element.innerHTML = " contents "; — appends contents to the DOM node
element.parentNode.removeChild(element); — remove the node from the DOM

element.hasAttribute(" attribute") — tests whether the DOM node has a specific attribute
element.getAttribute(" attribute") — returns the value of a specific attribute 
element.setAttribute(" name", " value ") — adds a specific attribute to the DOM node
element.removeAttribute(" attribute") —removes a specific attribute to the DOM node
Examples of built-in JS methods
element.classList.add() — adds a specific class to the DOM
element.classList.remove() — adds a specific class to the DOM
element.classList.toggle() — adds a specific class to the DOM

... and many more
Avoid using Regular expressions 
A complex Regex can be a performance killer
à 
when it’s possible, prefer HTML5 form validation attributes or String operations
Avoid using Regular expressions 
If the input of a form is known a priori, use HTML5 input types
http://mobiforge.com/design-development/html5-mobile-web-forms-and-input-types
date	

 tel	

 number
Roadmap
•  Use the DOM efficiently
•  Master events
•  Be smart with the network 
•  Take care of memory issues
•  Take advantage of CSS3 features
Events
name of the event
callback function
manage the event in
the capture phase
data about the event
Capturing and bubbling
When an event is triggered in the DOM, 
it will always start from the ROOT, and then it can be:

captured by all the elements containing the target element 
à event capturing

captured first by the target and then BUBBLE up through all 
the HTML elements containing the target
àevent bubbling
http://www.kirupa.com/html5/event_capturing_bubbling_javascript.htm
Event delegation









Delegation 
The act of establishing event handlers at higher levels in the DOM than the items of interest
Event throttling
delay

number of milliseconds
function

the function to be executed




•  Useful when 


handling events with very high frequencies and whose execution rate must be limited




 
ex. drag, scrolling, etc.
Throttling limits the execution rate of the function
Event debouncing
delay

number of milliseconds
function

the function to be executed




•  Useful when 


handling events with very high frequencies and that must be executed once

 

ex. toggle state, Ajax request, etc.
Debouncing guarantees that the function will be executed only once
Throttling VS debouncing
Throttling	

Debouncing	

Ben Alman’s famous implementations available here:
http://benalman.com/projects/jquery-throttle-debounce-plugin/
Roadmap
•  Use the DOM efficiently
•  Master events
•  Be smart with the network 
•  Take care of memory issues
•  Take advantage of CSS3 features
Network usage
•  Try to prefetch data as much as possible (possibly analysing their results in Web Workers)
•  Bundle static data into the app
•  In any case, give visual feedback to the user when accessing the network
The network is the most unpredictable and memory
consuming resource you have
http://fgnass.github.io/spin.js
Roadmap
•  Use the DOM efficiently
•  Master events
•  Be smart with the network 
•  Take care of memory issues
•  Take advantage of CSS3 features
Take care of memory issues





True, it automatically cleans up and deallocates memory, but it must be sure about what it is deleting forever


à you have to make it clear what code you are no longer using
Definition of memory leak
A memory leak is the situation in which the available memory of your app gets gradually lost

In JavaScript a memory leak can happen when an object is stored in memory but cannot be accessed by the
running code 

Wait, why should I worry if JavaScript has a garbage
collector that automatically cleans my memory?
Meet your best friend!
The retaining tree












The garbage collector cleans up the portions of tree isolated from the root node

In our apps the window object is the root of the tree


 https://developers.google.com/chrome-developer-tools/docs/javascript-memory-profiling
Rules of thumb




Better than de-referencing




Unbind events that are no longer needed, specially if the related DOM objects are going to be
removed




Be careful with storing large chunks of data that you are not going to use

Use local scope
Unbind event listeners
Manage local cache
http://slid.es/gruizdevilla/memory
The key is to always have
an healthy retaining tree
How to detect a memory leak
1.  Open the Memory View in the Timeline tab
2.  start recording
3.  execute the suspicious actions
4.  during the execution force a GC different times
5.  If you see a sawtooth-shaped wave

à no relevant memory leaks J
You have a memory leak if one of the following do not drop down:

used memory – number of DOM nodes – number of event handlers
http://goo.gl/UAZQvl
Examples of pattern
http://goo.gl/UAZQvl
No memory leak	

 Memory leak detected	

NOTHING IS FREE 
It’s normal that during the investigation your memory grows
You have to pay for what you are doing in your app
How to detect the source of your memory leak
1.  Open the Heap Profile 
2.  Take a heap snapshot
3.  Perform suspicious actions
4.  Take a heap snapshot
5.  Perform suspicious actions again
6.  Take a final heap snapshot
7.  Select the most recent snapshot taken
8.  find the drop-down that says "All objects" and switch it to "Objects allocated between snapshots 1 and
2". (You can also do the same for 2 and 3 if needed)
http://goo.gl/UAZQvl
There, you will find the objects which have not been collected during the snapshots
How to detect the source of your memory leak
Now, start from the first object and check which references it is holding

Shallow size
the size of the object 

Retain size 
the size of memory that can be freed once an object is deleted

Yellow DOM nodes
Red DOM nodes
 Detached DOM trees, no JS object is directly referencing them, but they are alive
some JS object is referencing them
Detached DOM tree is a subtree of the DOM that 
1)  has been removed from the DOM, and
2)  cannot be GCed because some JS object is still
indirectly referencing it
Example
http://goo.gl/UAZQvl
#leaf maintains a reference to it's parent (parentNode) and recursively up to #tree, 
so only when leafRef is nullified the WHOLE tree under #tree can be GCed.
Roadmap
•  Use the DOM efficiently
•  Master events
•  Be smart with the network 
•  Take care of memory issues
•  Take advantage of CSS3 features
Rule of thumb

Corollaries:
•  Don’t use JavaScript for UI-related operations
•  Don’t use images for something you can do with CSS
CSS3 has many interesting features, like:
•  text manipulations & effects
•  visual effects
•  media queries
•  ...
If you can do something with CSS, do it!
Text transforms
text-transform
none | capitalize | 
lowercase | uppercase
Text effects






2px à horizontal shadow 
10px à vertical shadow 
5px à blur distance 
#FF0000 à color
Visual effects

Three main mechanisms:

1.  Transforms (both 2D and 3D)
2.  Transitions
3.  Animations
Transforms
A transform is an effect that lets an element change shape, size, position, … 

You can transform your elements using 2D or 3D transformations

http://bit.ly/IroJ7S
Transforms
http://bit.ly/IrpUnX
Transforms
http://bit.ly/IrpUnX
Transitions

They are used to add an effect when changing from one style to another

The effect will start when the specified CSS property changes value


initial state
final state
Intermediate states
automatically calculated
time
Transition example
 Properties:
property – name of a CSS property
duration – #seconds to complete the transition
timing-­‐function - linear, ease, …
delay-­‐ when the transition effect will start
Animations
An animation is an effect that lets an element gradually change from one style to another

You can change style in loop, repeating, etc. 

initial state
 finalstate
Intermediate states
automatically calculated
time
Example of animation
result in
http://goo.gl/ejp4Fy
Transition VS animation
Trigger
Transitions must be bound to a CSS property change
Animations start autonomously

States
Transitions have start and end states
Animations can have multiple states

Repeats
Transitions can be perfomed once for each activation
Animations can be looped
Media queries
They allow you to to change style based on specific conditions


For example, they can be about
•  device’s display size
•  orientation of the device
•  resolution of the display
•  ...
http://bit.ly/I5mR1u
Examples
Retina Displays




iPad in landscape orientation




iPhone and Android devices
References
https://developer.mozilla.org/en-US/docs/JavaScript/Guide
https://github.com/iivanoo/cordovaboilerplate
+ 39 380 70 21 600
Contact
Ivano Malavolta | 
Gran Sasso Science Institute
iivanoo
ivano.malavolta@univaq.it
www.ivanomalavolta.com

More Related Content

What's hot

Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Doris Chen
 
[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 RefresherIvano Malavolta
 
Unobtrusive JavaScript with jQuery
Unobtrusive JavaScript with jQueryUnobtrusive JavaScript with jQuery
Unobtrusive JavaScript with jQuerySimon Willison
 
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar TechnologiesRob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologiesgeorge.james
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event HandlingWebStackAcademy
 
Ajax Overview by Bally Chohan
Ajax Overview by Bally ChohanAjax Overview by Bally Chohan
Ajax Overview by Bally ChohanWebVineet
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components EverywhereIlia Idakiev
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Railscodeinmotion
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQueryAlek Davis
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - DirectivesWebStackAcademy
 
Easy javascript
Easy javascriptEasy javascript
Easy javascriptBui Kiet
 
The Art of AngularJS in 2015
The Art of AngularJS in 2015The Art of AngularJS in 2015
The Art of AngularJS in 2015Matt Raible
 
JavaScript DOM Manipulations
JavaScript DOM ManipulationsJavaScript DOM Manipulations
JavaScript DOM ManipulationsYnon Perek
 
jQuery - Chapter 1 - Introduction
 jQuery - Chapter 1 - Introduction jQuery - Chapter 1 - Introduction
jQuery - Chapter 1 - IntroductionWebStackAcademy
 

What's hot (20)

Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!Angular or Backbone: Go Mobile!
Angular or Backbone: Go Mobile!
 
jQuery
jQueryjQuery
jQuery
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher
 
Unobtrusive JavaScript with jQuery
Unobtrusive JavaScript with jQueryUnobtrusive JavaScript with jQuery
Unobtrusive JavaScript with jQuery
 
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar TechnologiesRob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Ajax
AjaxAjax
Ajax
 
Ajax Overview by Bally Chohan
Ajax Overview by Bally ChohanAjax Overview by Bally Chohan
Ajax Overview by Bally Chohan
 
Show Some Spine!
Show Some Spine!Show Some Spine!
Show Some Spine!
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components Everywhere
 
Web Components
Web ComponentsWeb Components
Web Components
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Rest
Rest Rest
Rest
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
 
Easy javascript
Easy javascriptEasy javascript
Easy javascript
 
The Art of AngularJS in 2015
The Art of AngularJS in 2015The Art of AngularJS in 2015
The Art of AngularJS in 2015
 
JavaScript DOM Manipulations
JavaScript DOM ManipulationsJavaScript DOM Manipulations
JavaScript DOM Manipulations
 
jQuery - Chapter 1 - Introduction
 jQuery - Chapter 1 - Introduction jQuery - Chapter 1 - Introduction
jQuery - Chapter 1 - Introduction
 

Similar to Fast mobile web apps

Speeding up mobile web apps
Speeding up mobile web appsSpeeding up mobile web apps
Speeding up mobile web appsIvano Malavolta
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidStanojko Markovik
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Domkaven yan
 
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQueryUpstate CSCI 450 jQuery
Upstate CSCI 450 jQueryDanWooster1
 
Front-end optimisation & jQuery Internals
Front-end optimisation & jQuery InternalsFront-end optimisation & jQuery Internals
Front-end optimisation & jQuery InternalsArtur Cistov
 
Modern Web Technologies
Modern Web TechnologiesModern Web Technologies
Modern Web TechnologiesPerttu Myry
 
The Mysteries Of JavaScript-Fu (@media SF Edition)
The Mysteries Of JavaScript-Fu (@media SF Edition)The Mysteries Of JavaScript-Fu (@media SF Edition)
The Mysteries Of JavaScript-Fu (@media SF Edition)danwrong
 
Web Performance Tips
Web Performance TipsWeb Performance Tips
Web Performance TipsRavi Raj
 
Building high performance web apps.
Building high performance web apps.Building high performance web apps.
Building high performance web apps.Arshak Movsisyan
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK toolsHaribabu Nandyal Padmanaban
 
Xamarin.android memory management gotchas
Xamarin.android memory management gotchasXamarin.android memory management gotchas
Xamarin.android memory management gotchasAlec Tucker
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Modelchomas kandar
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Modelchomas kandar
 
Web Components
Web ComponentsWeb Components
Web ComponentsFITC
 
Business of Front-end Web Development
Business of Front-end Web DevelopmentBusiness of Front-end Web Development
Business of Front-end Web DevelopmentRachel Andrew
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Marco Breveglieri
 

Similar to Fast mobile web apps (20)

Speeding up mobile web apps
Speeding up mobile web appsSpeeding up mobile web apps
Speeding up mobile web apps
 
JavaScript and BOM events
JavaScript and BOM eventsJavaScript and BOM events
JavaScript and BOM events
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with android
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
 
Upstate CSCI 450 jQuery
Upstate CSCI 450 jQueryUpstate CSCI 450 jQuery
Upstate CSCI 450 jQuery
 
Front-end optimisation & jQuery Internals
Front-end optimisation & jQuery InternalsFront-end optimisation & jQuery Internals
Front-end optimisation & jQuery Internals
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
Modern Web Technologies
Modern Web TechnologiesModern Web Technologies
Modern Web Technologies
 
The Mysteries Of JavaScript-Fu (@media SF Edition)
The Mysteries Of JavaScript-Fu (@media SF Edition)The Mysteries Of JavaScript-Fu (@media SF Edition)
The Mysteries Of JavaScript-Fu (@media SF Edition)
 
All of javascript
All of javascriptAll of javascript
All of javascript
 
Web Performance Tips
Web Performance TipsWeb Performance Tips
Web Performance Tips
 
Building high performance web apps.
Building high performance web apps.Building high performance web apps.
Building high performance web apps.
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
 
Xamarin.android memory management gotchas
Xamarin.android memory management gotchasXamarin.android memory management gotchas
Xamarin.android memory management gotchas
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Web Components
Web ComponentsWeb Components
Web Components
 
SWTT 140407 session04
SWTT 140407 session04SWTT 140407 session04
SWTT 140407 session04
 
Business of Front-end Web Development
Business of Front-end Web DevelopmentBusiness of Front-end Web Development
Business of Front-end Web Development
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
 

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
 
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Collaborative Model-Driven Software Engineering: a Classification Framework a...Collaborative Model-Driven Software Engineering: a Classification Framework a...
Collaborative Model-Driven Software Engineering: a Classification Framework a...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
 
[2017/2018] Agile development
[2017/2018] Agile development[2017/2018] Agile development
[2017/2018] Agile developmentIvano 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
 

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]
 
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Collaborative Model-Driven Software Engineering: a Classification Framework a...Collaborative Model-Driven Software Engineering: a Classification Framework a...
Collaborative Model-Driven Software Engineering: a Classification Framework a...
 
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...
 
[2017/2018] Agile development
[2017/2018] Agile development[2017/2018] Agile development
[2017/2018] Agile development
 
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
 

Recently uploaded

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
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
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
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
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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
 

Recently uploaded (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
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)
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
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
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
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?
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 

Fast mobile web apps

  • 1. Gran Sasso Science Institute + Università degli Studi dell’Aquila Ivano Malavolta Fast mobile web apps
  • 2. Intro You will leave this presentation with... an understanding of what makes a mobile web app slow techniques to improve the performance of your mobile web apps In any case, step zero to success is to be technologically ready, for example many people tend to underestimate JavaScript, don't! http://eloquentjavascript.net
  • 3. Roadmap •  Use the DOM efficiently •  Master events •  Be smart with the network •  Take care of memory issues •  Take advantage of CSS3 features The best practices and advices in this presentation are implemented in a generic app template available here: https://github.com/iivanoo/cordovaboilerplate
  • 4. Always “cache” elements from the DOM every time you do $(‘id’) the browser must parse the whole DOM
  • 5. Minimize DOM reflows A reflow is triggered every time the content of the DOM changes, DOM elements are resized, CSS positioning/padding/margins are changed, etc. •  Use CSS transforms, transitions and animation •  Use fixed widths and heights (when possible) •  Avoid changing elements of the DOM They change the appearance of the DOM, but do not trigger a reflow op Reflow: the browser process for calculating positions and geometries for HTML DOM elements
  • 6. Keep your DOM slim Reflow operations are much heavier when •  the number of nodes in the DOM is large •  there are deeply nested DOM nodes Document HTML Body Element Element Element Element Element Element Element Element Element
  • 7. Navigate the DOM with built-in methods Avoid to continuously query the DOM if you can reach specific DOM nodes using its built-in methods
  • 8. Examples of built-in JS properties for navigation element.parentNode — returns the node containing the element in the DOM element.childNodes; — returns all the nested nodes of the element in the DOM element.firstChild — retrieves the first nested node of the element in the DOM element.lastChild — retrieves the last nested node of the element in the DOM element.nextSibling — returns the node immediately following the element in the DOM element.previousSibling — returns the node immediately preceding the element in the DOM
  • 9. Avoid to interact with the DOM too often Every time you append a node in the DOM, a reflow operation is triggered
  • 10. Prefer built-in JavaScript methods Under the lines, all JS frameworks end up in calling standard JavaScript methods à when it’s possible, prefer JavaScript built-in methods to pass through a framework Many frameworks contain a lot of workarounds and fallbacks for older browsers that we are not targeting (e.g., Internet Explorer 7)
  • 11. Examples of built-in JS methods element.innerHTML; — returns the contents of the DOM node element.innerHTML = " contents "; — appends contents to the DOM node element.parentNode.removeChild(element); — remove the node from the DOM element.hasAttribute(" attribute") — tests whether the DOM node has a specific attribute element.getAttribute(" attribute") — returns the value of a specific attribute element.setAttribute(" name", " value ") — adds a specific attribute to the DOM node element.removeAttribute(" attribute") —removes a specific attribute to the DOM node
  • 12. Examples of built-in JS methods element.classList.add() — adds a specific class to the DOM element.classList.remove() — adds a specific class to the DOM element.classList.toggle() — adds a specific class to the DOM ... and many more
  • 13. Avoid using Regular expressions A complex Regex can be a performance killer à when it’s possible, prefer HTML5 form validation attributes or String operations
  • 14. Avoid using Regular expressions If the input of a form is known a priori, use HTML5 input types http://mobiforge.com/design-development/html5-mobile-web-forms-and-input-types date tel number
  • 15. Roadmap •  Use the DOM efficiently •  Master events •  Be smart with the network •  Take care of memory issues •  Take advantage of CSS3 features
  • 16. Events name of the event callback function manage the event in the capture phase data about the event
  • 17. Capturing and bubbling When an event is triggered in the DOM, it will always start from the ROOT, and then it can be: captured by all the elements containing the target element à event capturing captured first by the target and then BUBBLE up through all the HTML elements containing the target àevent bubbling http://www.kirupa.com/html5/event_capturing_bubbling_javascript.htm
  • 18. Event delegation Delegation The act of establishing event handlers at higher levels in the DOM than the items of interest
  • 19. Event throttling delay number of milliseconds function the function to be executed •  Useful when handling events with very high frequencies and whose execution rate must be limited ex. drag, scrolling, etc. Throttling limits the execution rate of the function
  • 20. Event debouncing delay number of milliseconds function the function to be executed •  Useful when handling events with very high frequencies and that must be executed once ex. toggle state, Ajax request, etc. Debouncing guarantees that the function will be executed only once
  • 21. Throttling VS debouncing Throttling Debouncing Ben Alman’s famous implementations available here: http://benalman.com/projects/jquery-throttle-debounce-plugin/
  • 22. Roadmap •  Use the DOM efficiently •  Master events •  Be smart with the network •  Take care of memory issues •  Take advantage of CSS3 features
  • 23. Network usage •  Try to prefetch data as much as possible (possibly analysing their results in Web Workers) •  Bundle static data into the app •  In any case, give visual feedback to the user when accessing the network The network is the most unpredictable and memory consuming resource you have http://fgnass.github.io/spin.js
  • 24. Roadmap •  Use the DOM efficiently •  Master events •  Be smart with the network •  Take care of memory issues •  Take advantage of CSS3 features
  • 25. Take care of memory issues True, it automatically cleans up and deallocates memory, but it must be sure about what it is deleting forever à you have to make it clear what code you are no longer using Definition of memory leak A memory leak is the situation in which the available memory of your app gets gradually lost In JavaScript a memory leak can happen when an object is stored in memory but cannot be accessed by the running code Wait, why should I worry if JavaScript has a garbage collector that automatically cleans my memory?
  • 26. Meet your best friend!
  • 27. The retaining tree The garbage collector cleans up the portions of tree isolated from the root node In our apps the window object is the root of the tree https://developers.google.com/chrome-developer-tools/docs/javascript-memory-profiling
  • 28. Rules of thumb Better than de-referencing Unbind events that are no longer needed, specially if the related DOM objects are going to be removed Be careful with storing large chunks of data that you are not going to use Use local scope Unbind event listeners Manage local cache http://slid.es/gruizdevilla/memory The key is to always have an healthy retaining tree
  • 29. How to detect a memory leak 1.  Open the Memory View in the Timeline tab 2.  start recording 3.  execute the suspicious actions 4.  during the execution force a GC different times 5.  If you see a sawtooth-shaped wave à no relevant memory leaks J You have a memory leak if one of the following do not drop down: used memory – number of DOM nodes – number of event handlers http://goo.gl/UAZQvl
  • 30. Examples of pattern http://goo.gl/UAZQvl No memory leak Memory leak detected NOTHING IS FREE It’s normal that during the investigation your memory grows You have to pay for what you are doing in your app
  • 31. How to detect the source of your memory leak 1.  Open the Heap Profile 2.  Take a heap snapshot 3.  Perform suspicious actions 4.  Take a heap snapshot 5.  Perform suspicious actions again 6.  Take a final heap snapshot 7.  Select the most recent snapshot taken 8.  find the drop-down that says "All objects" and switch it to "Objects allocated between snapshots 1 and 2". (You can also do the same for 2 and 3 if needed) http://goo.gl/UAZQvl There, you will find the objects which have not been collected during the snapshots
  • 32. How to detect the source of your memory leak Now, start from the first object and check which references it is holding Shallow size the size of the object Retain size the size of memory that can be freed once an object is deleted Yellow DOM nodes Red DOM nodes Detached DOM trees, no JS object is directly referencing them, but they are alive some JS object is referencing them Detached DOM tree is a subtree of the DOM that 1)  has been removed from the DOM, and 2)  cannot be GCed because some JS object is still indirectly referencing it
  • 33. Example http://goo.gl/UAZQvl #leaf maintains a reference to it's parent (parentNode) and recursively up to #tree, so only when leafRef is nullified the WHOLE tree under #tree can be GCed.
  • 34. Roadmap •  Use the DOM efficiently •  Master events •  Be smart with the network •  Take care of memory issues •  Take advantage of CSS3 features
  • 35. Rule of thumb Corollaries: •  Don’t use JavaScript for UI-related operations •  Don’t use images for something you can do with CSS CSS3 has many interesting features, like: •  text manipulations & effects •  visual effects •  media queries •  ... If you can do something with CSS, do it!
  • 36. Text transforms text-transform none | capitalize | lowercase | uppercase
  • 37. Text effects 2px à horizontal shadow 10px à vertical shadow 5px à blur distance #FF0000 à color
  • 38. Visual effects Three main mechanisms: 1.  Transforms (both 2D and 3D) 2.  Transitions 3.  Animations
  • 39. Transforms A transform is an effect that lets an element change shape, size, position, … You can transform your elements using 2D or 3D transformations http://bit.ly/IroJ7S
  • 42. Transitions They are used to add an effect when changing from one style to another The effect will start when the specified CSS property changes value initial state final state Intermediate states automatically calculated time
  • 43. Transition example Properties: property – name of a CSS property duration – #seconds to complete the transition timing-­‐function - linear, ease, … delay-­‐ when the transition effect will start
  • 44. Animations An animation is an effect that lets an element gradually change from one style to another You can change style in loop, repeating, etc. initial state finalstate Intermediate states automatically calculated time
  • 45. Example of animation result in http://goo.gl/ejp4Fy
  • 46. Transition VS animation Trigger Transitions must be bound to a CSS property change Animations start autonomously States Transitions have start and end states Animations can have multiple states Repeats Transitions can be perfomed once for each activation Animations can be looped
  • 47. Media queries They allow you to to change style based on specific conditions For example, they can be about •  device’s display size •  orientation of the device •  resolution of the display •  ... http://bit.ly/I5mR1u
  • 48. Examples Retina Displays iPad in landscape orientation iPhone and Android devices
  • 50. + 39 380 70 21 600 Contact Ivano Malavolta | Gran Sasso Science Institute iivanoo ivano.malavolta@univaq.it www.ivanomalavolta.com