SlideShare uma empresa Scribd logo
1 de 33
1
Optimizing Browser DOM
Rendering
Michael Labriola - @mlabriola
Senior Consultant w/ Digital Primates
Session Expectations - Performance
This session is about performance optimization but it‟s not
an absolute thing.
Performance has both subjective and absolute aspects
• Perceived performance can be the difference between a
user‟s willingness to use an application or abandon it
• Raw computational work may decide which devices can use
your work effectively and for how long
2
Session Expectations - Optimization
Performance Optimization is similarly difficult.
• An optimization in one situation can unintentionally degrade
performance in another
• Optimization is more about understanding a range of
possibilities and trying to find the sweet spot for your purpose
Performance advice is usually about what to do, but it‟s
contextual.
• Context is just often lost in the explanation.
• Performance related advice can often appear conflicting
• There are exceptions
• Much of the advice you can find online is out of date
3
Session Expectations - Goal
This presentation is about understanding the browser
• Understanding internals helps you build a mental model
• The real goal is to know why to do something
This is a big topic that we could talk about for days.
Alas, we have an hour, so:
• I won‟t get to cover everything I want
• I won‟t get to dive into the depth that I desire
• This is my best to balance at a lot of theory and practical ways
to apply
4
Disclaimer
Unfortunately, with this type of technical content I need a
disclaimer.
Applicability
• This advice is generally for Webkit-based rendering
• Most of it is identical for Gecko (Firefox), although some of the
terminology is different
• Internet Explorer
• Most of the general advice is still valid for IE
• There are major differences in the way IE7, IE8 and IE9 handle
some of these things
• I am not saying to ignore IE. The general advice is good and
then its worth while to experiment and test on IE.
5
Jumping In
When you navigate to a URL, a web page is loaded by a
Loader. Let‟s call the result of that load operation „tag soup‟
for now.
Tag soup needs to get parsed
6
The goal of the parsing step is to create something we call
the DOM tree. In a perfect world it might look like this:
Parsing
7
<html>
<head>
<title>Yo!</title>
</head>
<body>
<div>
<img src="ncdev.jpg">
</div>
<div><p>Dev Con</p></div>
</body>
</html>
Parsing – Best Guess
Unfortunately HTML isn‟t always perfect, so the parser has
to make some best guesses and try to bring something
together:
8
<html>
<head>
<title>Yo!</title>
</head>
<body>
<div>
<img src="ncdev.jpg">
</div>
<div><p>Dev Con
</body>
</html>
Parsing – Best Guess Gone Wrong
..and those guesses may not be what you expected. So,
validate your HTML, save the parser some effort and you
some sanity.
9
<html>
<head>
<title>Yo!</title>
</head>
<body>
<div>
<img src="ncdev.jpg">
<div><p>Dev Con
</body>
</html>
Waterfall
Modern browsers do some optimistic look-aheads, if the
parser is ever blocked/waiting, the browser begins
downloading other external content it will also need
10
CSS
The combination of default style sheets, inline styles, inline
CSS and CSS Loaded from external files provides
information we use for layout and styling. So, we build a tree
(actually a few and some more data structures)
11
p,div{
margin-top:3px;
}
.error {
color:red;
}
DOM and CSS sitting in a Tree
Information from the DOM tree and the Style Structures are
used to form the Render Tree. The Render Tree holds the
information about what gets painted on the screen.
12
CSS Style Matching
CSS styles are stored into various maps so that they can be
easily retrieved later.
13
div {
font-size: 11pt;
}
table div {
font-size: 12pt;
}
#theId {
display: none;
}
.myClass {
color: #ff0000;
}
Tag
ID
Class
<div>
<img src="foo.jpg">
</div>
<div>
<p>NCDev</p>
</div>
<p id="theId"></p>
<p class="myClass"></p>
Quick Advice on CSS
Specificity is important, but the rule be as specific as
possible is confusing. From a pure performance standpoint
• ID Selectors followed by Class Selectors are very fast
• Further clarifying these is NOT helpful, its slower
p.myClass table#thingy
• Descendant Selectors and Child Selectors should be avoided
whenever humanly possible
.myul_in_a_div {}
versus
ul div {}
14
CSS Caveats
Caveats - How specific a selector is determines its weight
when styles cascade
• It‟s from is a 'style' attribute rather than a rule with a selector
• The number of ID attributes in the selector
• The number of other attributes and pseudo-classes in the
selector
• The number of element names and pseudo-elements in the
selector
15
Understanding the Render Tree
The render tree is about the visual aspects of your display
16
div {
font-size: 11pt;
}
img {
display: none;
}
Putting it all together
Manipulating the DOM is the slowest thing we can do in the
web environment. Depending on what we do, the browser
needs to mark things as invalid. The process of making
them valid again means executing parts of this diagram.
17
Repaint Only
If we are careful and just make changes to things like color,
visibility or other changes that don‟t require new
measurement and layout, we can often just execute this part
of the chart:
18
Re-layout/Flow
If we make any change that requires that causes a size or
positioning difference we need to minimally executed these
parts of the chart.
19
Do Less Work
The simple truth behind making DOM interactions faster is
to do less of it…
A few ways to do less
• Execute the smallest amount of that flow chart that you can at
any time
• Actively worry if your choices make the browser execute any
part of it multiple times in a row
• Pay attention to how much of the trees your impacting
• Do your best to let the browser do this work when it is ready
20
Tooling
There are many excellent tools you can use to debug and
look into the information we are about to discuss. We are
just going to use Chrome‟s built in tooling for the moment,
but here are some resources:
21
 YSlow
 Chrome Plugin
 Firefox
 Speed Tracer
 Chrome Plugin
 FireBug
 Firefox
 dynaTrace (5 day
trial)
 IE Extension
 Firefox
 jsPerf
 Webpagetest.org
 (More every 5
minutes)
Chrome‟s Tools
Chrome has a great set of tools that will get us started and
they are all built in
Tools
• Network View
• Timeline
• CSS Profiler
22
Render Information
• Paint Rectangles
• Composited Layer Borders
• FPS Meter
• Continuous Page Repainting
Example 1 – Sized versus Non-Sized
Regions/Images
Really old statement everyone knows:
• Whenever possible, you should provide a width and
height for your images
Why?
23
Example 2 – Visibility versus Display None
Performance Statement:
• You should/shouldn‟t use visibility/display none when you
want to hide something.
Why?
24
Example 3 – Synchronous Layout
Performance Statement:
• You need to batch your changes to the DOM. Always try
to make a single class change versus multiple changes.
Why?
25
Example 4 – Off Dom Manipulation
Performance Statement:
• If you have to make DOM changes, you should make
them „off dom‟
Why?
26
Do Less Work Sooner
The perceived responsiveness of your page/application also
depends on how quickly it starts up.
This ultimately comes down to a few factors
• How much do we need to load on startup?
• How quickly can we load it?
• How much work must we do when everything arrives?
27
Example 6 – CSS Serial Loading
Performance Statement:
• Using CSS @import can slow down your page load
Why?
28
Example 7 – CSS Media Queries
Performance Statement:
• CSS Media Queries are good/bad for performance
Why?
29
Example 8 – Forced Synchronous Loading
Performance Statement:
• The order between external CSS and external Scripts in
the browser can have major performance implications
Why?
30
Example 9 – Script Placement
Performance Statement:
• Your scripts need to be at the top/bottom of your page at
all times.
Why?
31
Selected Resources
WebCore Rendering – Parts I through IV
https://www.webkit.org/blog/114/webcore-rendering-i-the-basics/
How Browsers Work: Behind the scenes of modern web browsers
http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/
Grosskurth, Alan. A Reference Architecture for Web Browsers
http://grosskurth.ca/papers/browser-refarch.pdf
The new game show: “Will it reflow?”
http://www.phpied.com/the-new-game-show-will-it-reflow/
…more to be posted…
32
33
Optimizing Browser DOM
Rendering
Michael Labriola - @mlabriola
Senior Consultant w/ Digital Primates

Mais conteúdo relacionado

Mais procurados

XPages Workshop: Customizing OneUI
XPages Workshop: Customizing OneUIXPages Workshop: Customizing OneUI
XPages Workshop: Customizing OneUIMichael McGarel
 
Wireless Wednesdays: Part 4
Wireless Wednesdays: Part 4Wireless Wednesdays: Part 4
Wireless Wednesdays: Part 4Teamstudio
 
Tip from ConnectED 2015: How to Use Those Cool New Frameworks in Mobile Domin...
Tip from ConnectED 2015: How to Use Those Cool New Frameworks in Mobile Domin...Tip from ConnectED 2015: How to Use Those Cool New Frameworks in Mobile Domin...
Tip from ConnectED 2015: How to Use Those Cool New Frameworks in Mobile Domin...SocialBiz UserGroup
 
Twelve Tasks Made Easier with IBM Domino XPages
Twelve Tasks Made Easier with IBM Domino XPagesTwelve Tasks Made Easier with IBM Domino XPages
Twelve Tasks Made Easier with IBM Domino XPagesTeamstudio
 
We4IT lcty 2013 - infra-man - whats new in ibm domino application development
We4IT lcty 2013 - infra-man - whats new in ibm domino application developmentWe4IT lcty 2013 - infra-man - whats new in ibm domino application development
We4IT lcty 2013 - infra-man - whats new in ibm domino application developmentWe4IT Group
 
Presenting Data – An Alternative to the View Control
Presenting Data – An Alternative to the View ControlPresenting Data – An Alternative to the View Control
Presenting Data – An Alternative to the View ControlTeamstudio
 
Building DotNetNuke Modules
Building DotNetNuke ModulesBuilding DotNetNuke Modules
Building DotNetNuke ModulesEngage Software
 
Becoming an IBM Connections Developer
Becoming an IBM Connections DeveloperBecoming an IBM Connections Developer
Becoming an IBM Connections DeveloperRob Novak
 
SharePoint 2010 Web Standards & Accessibility
SharePoint 2010 Web Standards & AccessibilitySharePoint 2010 Web Standards & Accessibility
SharePoint 2010 Web Standards & AccessibilityMavention
 
Fast Cordova applications
Fast Cordova applicationsFast Cordova applications
Fast Cordova applicationsIvano Malavolta
 
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
JMP402 Master Class: Managed beans and XPages: Your Time Is NowJMP402 Master Class: Managed beans and XPages: Your Time Is Now
JMP402 Master Class: Managed beans and XPages: Your Time Is NowRussell Maher
 
Tips for Building your First XPages Java Application
Tips for Building your First XPages Java ApplicationTips for Building your First XPages Java Application
Tips for Building your First XPages Java ApplicationTeamstudio
 
XPages: No Experience Needed
XPages: No Experience NeededXPages: No Experience Needed
XPages: No Experience NeededKathy Brown
 
Meet Magento Belarus 2015: Mladen Ristić
Meet Magento Belarus 2015: Mladen RistićMeet Magento Belarus 2015: Mladen Ristić
Meet Magento Belarus 2015: Mladen RistićAmasty
 
Mobilize Your Business, Not Just an App
Mobilize Your Business, Not Just an AppMobilize Your Business, Not Just an App
Mobilize Your Business, Not Just an AppTeamstudio
 
SHOW301 - Make Your IBM Connections Deployment Your Own: Customize It!
SHOW301 - Make Your IBM Connections Deployment Your Own: Customize It!SHOW301 - Make Your IBM Connections Deployment Your Own: Customize It!
SHOW301 - Make Your IBM Connections Deployment Your Own: Customize It!Klaus Bild
 
IBM Presents the Notes Domino Roadmap and a Deep Dive into Feature Pack 8
IBM Presents the Notes Domino Roadmap and a Deep Dive into Feature Pack 8IBM Presents the Notes Domino Roadmap and a Deep Dive into Feature Pack 8
IBM Presents the Notes Domino Roadmap and a Deep Dive into Feature Pack 8Teamstudio
 

Mais procurados (20)

XPages Workshop: Customizing OneUI
XPages Workshop: Customizing OneUIXPages Workshop: Customizing OneUI
XPages Workshop: Customizing OneUI
 
Wireless Wednesdays: Part 4
Wireless Wednesdays: Part 4Wireless Wednesdays: Part 4
Wireless Wednesdays: Part 4
 
Tip from ConnectED 2015: How to Use Those Cool New Frameworks in Mobile Domin...
Tip from ConnectED 2015: How to Use Those Cool New Frameworks in Mobile Domin...Tip from ConnectED 2015: How to Use Those Cool New Frameworks in Mobile Domin...
Tip from ConnectED 2015: How to Use Those Cool New Frameworks in Mobile Domin...
 
Twelve Tasks Made Easier with IBM Domino XPages
Twelve Tasks Made Easier with IBM Domino XPagesTwelve Tasks Made Easier with IBM Domino XPages
Twelve Tasks Made Easier with IBM Domino XPages
 
We4IT lcty 2013 - infra-man - whats new in ibm domino application development
We4IT lcty 2013 - infra-man - whats new in ibm domino application developmentWe4IT lcty 2013 - infra-man - whats new in ibm domino application development
We4IT lcty 2013 - infra-man - whats new in ibm domino application development
 
Presenting Data – An Alternative to the View Control
Presenting Data – An Alternative to the View ControlPresenting Data – An Alternative to the View Control
Presenting Data – An Alternative to the View Control
 
Building DotNetNuke Modules
Building DotNetNuke ModulesBuilding DotNetNuke Modules
Building DotNetNuke Modules
 
Becoming an IBM Connections Developer
Becoming an IBM Connections DeveloperBecoming an IBM Connections Developer
Becoming an IBM Connections Developer
 
Using Features
Using FeaturesUsing Features
Using Features
 
SharePoint 2010 Web Standards & Accessibility
SharePoint 2010 Web Standards & AccessibilitySharePoint 2010 Web Standards & Accessibility
SharePoint 2010 Web Standards & Accessibility
 
Fast Cordova applications
Fast Cordova applicationsFast Cordova applications
Fast Cordova applications
 
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
JMP402 Master Class: Managed beans and XPages: Your Time Is NowJMP402 Master Class: Managed beans and XPages: Your Time Is Now
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
 
Tips for Building your First XPages Java Application
Tips for Building your First XPages Java ApplicationTips for Building your First XPages Java Application
Tips for Building your First XPages Java Application
 
XPages: No Experience Needed
XPages: No Experience NeededXPages: No Experience Needed
XPages: No Experience Needed
 
Meet Magento Belarus 2015: Mladen Ristić
Meet Magento Belarus 2015: Mladen RistićMeet Magento Belarus 2015: Mladen Ristić
Meet Magento Belarus 2015: Mladen Ristić
 
An Overview Of Wpf
An Overview Of WpfAn Overview Of Wpf
An Overview Of Wpf
 
HTML5
HTML5 HTML5
HTML5
 
Mobilize Your Business, Not Just an App
Mobilize Your Business, Not Just an AppMobilize Your Business, Not Just an App
Mobilize Your Business, Not Just an App
 
SHOW301 - Make Your IBM Connections Deployment Your Own: Customize It!
SHOW301 - Make Your IBM Connections Deployment Your Own: Customize It!SHOW301 - Make Your IBM Connections Deployment Your Own: Customize It!
SHOW301 - Make Your IBM Connections Deployment Your Own: Customize It!
 
IBM Presents the Notes Domino Roadmap and a Deep Dive into Feature Pack 8
IBM Presents the Notes Domino Roadmap and a Deep Dive into Feature Pack 8IBM Presents the Notes Domino Roadmap and a Deep Dive into Feature Pack 8
IBM Presents the Notes Domino Roadmap and a Deep Dive into Feature Pack 8
 

Semelhante a Optimizing Browser Rendering

A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5SSW
 
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...John McCaffrey
 
Windy cityrails performance_tuning
Windy cityrails performance_tuningWindy cityrails performance_tuning
Windy cityrails performance_tuningJohn McCaffrey
 
How to write an application and not roll down to 1 fps
How to write an application and not roll down to 1 fpsHow to write an application and not roll down to 1 fps
How to write an application and not roll down to 1 fpsIntexSoft
 
Improving frontend performance
Improving frontend performanceImproving frontend performance
Improving frontend performanceSagar Desarda
 
Web Components
Web ComponentsWeb Components
Web ComponentsFITC
 
Edge 2014: Maintaining the Balance: Getting the Most of Your CDN with IKEA
Edge 2014: Maintaining the Balance: Getting the Most of Your CDN with IKEAEdge 2014: Maintaining the Balance: Getting the Most of Your CDN with IKEA
Edge 2014: Maintaining the Balance: Getting the Most of Your CDN with IKEAAkamai Technologies
 
Grokking TechTalk #16: Html js and three way binding
Grokking TechTalk #16: Html js and three way bindingGrokking TechTalk #16: Html js and three way binding
Grokking TechTalk #16: Html js and three way bindingGrokking VN
 
Managing the Complexities of Conversion to S1000D
Managing the Complexities of Conversion to S1000DManaging the Complexities of Conversion to S1000D
Managing the Complexities of Conversion to S1000Ddclsocialmedia
 
Angular Ivy- An Overview
Angular Ivy- An OverviewAngular Ivy- An Overview
Angular Ivy- An OverviewJalpesh Vadgama
 
Performace optimization (increase website speed)
Performace optimization (increase website speed)Performace optimization (increase website speed)
Performace optimization (increase website speed)clickramanm
 
Evolutionary software design
Evolutionary software designEvolutionary software design
Evolutionary software designLior Bar-On
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara AnjargolianHakka Labs
 
Front End: Building Future-Proof eCommerce Sites.pdf
Front End: Building Future-Proof eCommerce Sites.pdfFront End: Building Future-Proof eCommerce Sites.pdf
Front End: Building Future-Proof eCommerce Sites.pdfWP Engine
 
Improving Drupal Performances
Improving Drupal PerformancesImproving Drupal Performances
Improving Drupal PerformancesVladimir Ilic
 
Web Client Performance
Web Client PerformanceWeb Client Performance
Web Client PerformanceHerea Adrian
 
11 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 201411 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 2014WordPressBrisbane
 
XPages Blast - Ideas, Tips and More
XPages Blast - Ideas, Tips and MoreXPages Blast - Ideas, Tips and More
XPages Blast - Ideas, Tips and MoreTeamstudio
 
Choices for Responsive Redesign: Ground-up or Responsive Retrofit
Choices for Responsive Redesign: Ground-up or Responsive RetrofitChoices for Responsive Redesign: Ground-up or Responsive Retrofit
Choices for Responsive Redesign: Ground-up or Responsive RetrofitCantina
 

Semelhante a Optimizing Browser Rendering (20)

SMX_DevTools_Monaco_2.pdf
SMX_DevTools_Monaco_2.pdfSMX_DevTools_Monaco_2.pdf
SMX_DevTools_Monaco_2.pdf
 
A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5
 
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
 
Windy cityrails performance_tuning
Windy cityrails performance_tuningWindy cityrails performance_tuning
Windy cityrails performance_tuning
 
How to write an application and not roll down to 1 fps
How to write an application and not roll down to 1 fpsHow to write an application and not roll down to 1 fps
How to write an application and not roll down to 1 fps
 
Improving frontend performance
Improving frontend performanceImproving frontend performance
Improving frontend performance
 
Web Components
Web ComponentsWeb Components
Web Components
 
Edge 2014: Maintaining the Balance: Getting the Most of Your CDN with IKEA
Edge 2014: Maintaining the Balance: Getting the Most of Your CDN with IKEAEdge 2014: Maintaining the Balance: Getting the Most of Your CDN with IKEA
Edge 2014: Maintaining the Balance: Getting the Most of Your CDN with IKEA
 
Grokking TechTalk #16: Html js and three way binding
Grokking TechTalk #16: Html js and three way bindingGrokking TechTalk #16: Html js and three way binding
Grokking TechTalk #16: Html js and three way binding
 
Managing the Complexities of Conversion to S1000D
Managing the Complexities of Conversion to S1000DManaging the Complexities of Conversion to S1000D
Managing the Complexities of Conversion to S1000D
 
Angular Ivy- An Overview
Angular Ivy- An OverviewAngular Ivy- An Overview
Angular Ivy- An Overview
 
Performace optimization (increase website speed)
Performace optimization (increase website speed)Performace optimization (increase website speed)
Performace optimization (increase website speed)
 
Evolutionary software design
Evolutionary software designEvolutionary software design
Evolutionary software design
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara Anjargolian
 
Front End: Building Future-Proof eCommerce Sites.pdf
Front End: Building Future-Proof eCommerce Sites.pdfFront End: Building Future-Proof eCommerce Sites.pdf
Front End: Building Future-Proof eCommerce Sites.pdf
 
Improving Drupal Performances
Improving Drupal PerformancesImproving Drupal Performances
Improving Drupal Performances
 
Web Client Performance
Web Client PerformanceWeb Client Performance
Web Client Performance
 
11 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 201411 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 2014
 
XPages Blast - Ideas, Tips and More
XPages Blast - Ideas, Tips and MoreXPages Blast - Ideas, Tips and More
XPages Blast - Ideas, Tips and More
 
Choices for Responsive Redesign: Ground-up or Responsive Retrofit
Choices for Responsive Redesign: Ground-up or Responsive RetrofitChoices for Responsive Redesign: Ground-up or Responsive Retrofit
Choices for Responsive Redesign: Ground-up or Responsive Retrofit
 

Mais de michael.labriola

Flex 4 components from the firehose
Flex 4 components from the firehoseFlex 4 components from the firehose
Flex 4 components from the firehosemichael.labriola
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audiencemichael.labriola
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audiencemichael.labriola
 
FlexUnit 4 for contributors
FlexUnit 4 for contributorsFlexUnit 4 for contributors
FlexUnit 4 for contributorsmichael.labriola
 
Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy michael.labriola
 
Flex 4 Component Development
Flex 4 Component DevelopmentFlex 4 Component Development
Flex 4 Component Developmentmichael.labriola
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flexmichael.labriola
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Watersmichael.labriola
 
How To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex InfrastructureHow To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex Infrastructuremichael.labriola
 
2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Componentsmichael.labriola
 

Mais de michael.labriola (19)

L2624 labriola
L2624 labriolaL2624 labriola
L2624 labriola
 
Talking trash
Talking trashTalking trash
Talking trash
 
Flex 4 components from the firehose
Flex 4 components from the firehoseFlex 4 components from the firehose
Flex 4 components from the firehose
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audience
 
Developing for a world wide audience
Developing for a world wide audienceDeveloping for a world wide audience
Developing for a world wide audience
 
FlexUnit 4 for contributors
FlexUnit 4 for contributorsFlexUnit 4 for contributors
FlexUnit 4 for contributors
 
Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy Write once... Take Less Time to Deploy
Write once... Take Less Time to Deploy
 
Why test with flex unit
Why test with flex unitWhy test with flex unit
Why test with flex unit
 
Apocalypse Soon
Apocalypse SoonApocalypse Soon
Apocalypse Soon
 
Flex 4 Component Development
Flex 4 Component DevelopmentFlex 4 Component Development
Flex 4 Component Development
 
Any Which Array But Loose
Any Which Array But LooseAny Which Array But Loose
Any Which Array But Loose
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Air Drag And Drop
Air Drag And DropAir Drag And Drop
Air Drag And Drop
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Waters
 
How To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex InfrastructureHow To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex Infrastructure
 
Blaze Ds Slides
Blaze Ds SlidesBlaze Ds Slides
Blaze Ds Slides
 
2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components2007 Max Presentation - Creating Custom Flex Components
2007 Max Presentation - Creating Custom Flex Components
 
Dense And Hot 360 Flex
Dense And Hot 360 FlexDense And Hot 360 Flex
Dense And Hot 360 Flex
 
Dense And Hot Web Du
Dense And Hot  Web DuDense And Hot  Web Du
Dense And Hot Web Du
 

Último

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Optimizing Browser Rendering

  • 1. 1 Optimizing Browser DOM Rendering Michael Labriola - @mlabriola Senior Consultant w/ Digital Primates
  • 2. Session Expectations - Performance This session is about performance optimization but it‟s not an absolute thing. Performance has both subjective and absolute aspects • Perceived performance can be the difference between a user‟s willingness to use an application or abandon it • Raw computational work may decide which devices can use your work effectively and for how long 2
  • 3. Session Expectations - Optimization Performance Optimization is similarly difficult. • An optimization in one situation can unintentionally degrade performance in another • Optimization is more about understanding a range of possibilities and trying to find the sweet spot for your purpose Performance advice is usually about what to do, but it‟s contextual. • Context is just often lost in the explanation. • Performance related advice can often appear conflicting • There are exceptions • Much of the advice you can find online is out of date 3
  • 4. Session Expectations - Goal This presentation is about understanding the browser • Understanding internals helps you build a mental model • The real goal is to know why to do something This is a big topic that we could talk about for days. Alas, we have an hour, so: • I won‟t get to cover everything I want • I won‟t get to dive into the depth that I desire • This is my best to balance at a lot of theory and practical ways to apply 4
  • 5. Disclaimer Unfortunately, with this type of technical content I need a disclaimer. Applicability • This advice is generally for Webkit-based rendering • Most of it is identical for Gecko (Firefox), although some of the terminology is different • Internet Explorer • Most of the general advice is still valid for IE • There are major differences in the way IE7, IE8 and IE9 handle some of these things • I am not saying to ignore IE. The general advice is good and then its worth while to experiment and test on IE. 5
  • 6. Jumping In When you navigate to a URL, a web page is loaded by a Loader. Let‟s call the result of that load operation „tag soup‟ for now. Tag soup needs to get parsed 6
  • 7. The goal of the parsing step is to create something we call the DOM tree. In a perfect world it might look like this: Parsing 7 <html> <head> <title>Yo!</title> </head> <body> <div> <img src="ncdev.jpg"> </div> <div><p>Dev Con</p></div> </body> </html>
  • 8. Parsing – Best Guess Unfortunately HTML isn‟t always perfect, so the parser has to make some best guesses and try to bring something together: 8 <html> <head> <title>Yo!</title> </head> <body> <div> <img src="ncdev.jpg"> </div> <div><p>Dev Con </body> </html>
  • 9. Parsing – Best Guess Gone Wrong ..and those guesses may not be what you expected. So, validate your HTML, save the parser some effort and you some sanity. 9 <html> <head> <title>Yo!</title> </head> <body> <div> <img src="ncdev.jpg"> <div><p>Dev Con </body> </html>
  • 10. Waterfall Modern browsers do some optimistic look-aheads, if the parser is ever blocked/waiting, the browser begins downloading other external content it will also need 10
  • 11. CSS The combination of default style sheets, inline styles, inline CSS and CSS Loaded from external files provides information we use for layout and styling. So, we build a tree (actually a few and some more data structures) 11 p,div{ margin-top:3px; } .error { color:red; }
  • 12. DOM and CSS sitting in a Tree Information from the DOM tree and the Style Structures are used to form the Render Tree. The Render Tree holds the information about what gets painted on the screen. 12
  • 13. CSS Style Matching CSS styles are stored into various maps so that they can be easily retrieved later. 13 div { font-size: 11pt; } table div { font-size: 12pt; } #theId { display: none; } .myClass { color: #ff0000; } Tag ID Class <div> <img src="foo.jpg"> </div> <div> <p>NCDev</p> </div> <p id="theId"></p> <p class="myClass"></p>
  • 14. Quick Advice on CSS Specificity is important, but the rule be as specific as possible is confusing. From a pure performance standpoint • ID Selectors followed by Class Selectors are very fast • Further clarifying these is NOT helpful, its slower p.myClass table#thingy • Descendant Selectors and Child Selectors should be avoided whenever humanly possible .myul_in_a_div {} versus ul div {} 14
  • 15. CSS Caveats Caveats - How specific a selector is determines its weight when styles cascade • It‟s from is a 'style' attribute rather than a rule with a selector • The number of ID attributes in the selector • The number of other attributes and pseudo-classes in the selector • The number of element names and pseudo-elements in the selector 15
  • 16. Understanding the Render Tree The render tree is about the visual aspects of your display 16 div { font-size: 11pt; } img { display: none; }
  • 17. Putting it all together Manipulating the DOM is the slowest thing we can do in the web environment. Depending on what we do, the browser needs to mark things as invalid. The process of making them valid again means executing parts of this diagram. 17
  • 18. Repaint Only If we are careful and just make changes to things like color, visibility or other changes that don‟t require new measurement and layout, we can often just execute this part of the chart: 18
  • 19. Re-layout/Flow If we make any change that requires that causes a size or positioning difference we need to minimally executed these parts of the chart. 19
  • 20. Do Less Work The simple truth behind making DOM interactions faster is to do less of it… A few ways to do less • Execute the smallest amount of that flow chart that you can at any time • Actively worry if your choices make the browser execute any part of it multiple times in a row • Pay attention to how much of the trees your impacting • Do your best to let the browser do this work when it is ready 20
  • 21. Tooling There are many excellent tools you can use to debug and look into the information we are about to discuss. We are just going to use Chrome‟s built in tooling for the moment, but here are some resources: 21  YSlow  Chrome Plugin  Firefox  Speed Tracer  Chrome Plugin  FireBug  Firefox  dynaTrace (5 day trial)  IE Extension  Firefox  jsPerf  Webpagetest.org  (More every 5 minutes)
  • 22. Chrome‟s Tools Chrome has a great set of tools that will get us started and they are all built in Tools • Network View • Timeline • CSS Profiler 22 Render Information • Paint Rectangles • Composited Layer Borders • FPS Meter • Continuous Page Repainting
  • 23. Example 1 – Sized versus Non-Sized Regions/Images Really old statement everyone knows: • Whenever possible, you should provide a width and height for your images Why? 23
  • 24. Example 2 – Visibility versus Display None Performance Statement: • You should/shouldn‟t use visibility/display none when you want to hide something. Why? 24
  • 25. Example 3 – Synchronous Layout Performance Statement: • You need to batch your changes to the DOM. Always try to make a single class change versus multiple changes. Why? 25
  • 26. Example 4 – Off Dom Manipulation Performance Statement: • If you have to make DOM changes, you should make them „off dom‟ Why? 26
  • 27. Do Less Work Sooner The perceived responsiveness of your page/application also depends on how quickly it starts up. This ultimately comes down to a few factors • How much do we need to load on startup? • How quickly can we load it? • How much work must we do when everything arrives? 27
  • 28. Example 6 – CSS Serial Loading Performance Statement: • Using CSS @import can slow down your page load Why? 28
  • 29. Example 7 – CSS Media Queries Performance Statement: • CSS Media Queries are good/bad for performance Why? 29
  • 30. Example 8 – Forced Synchronous Loading Performance Statement: • The order between external CSS and external Scripts in the browser can have major performance implications Why? 30
  • 31. Example 9 – Script Placement Performance Statement: • Your scripts need to be at the top/bottom of your page at all times. Why? 31
  • 32. Selected Resources WebCore Rendering – Parts I through IV https://www.webkit.org/blog/114/webcore-rendering-i-the-basics/ How Browsers Work: Behind the scenes of modern web browsers http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/ Grosskurth, Alan. A Reference Architecture for Web Browsers http://grosskurth.ca/papers/browser-refarch.pdf The new game show: “Will it reflow?” http://www.phpied.com/the-new-game-show-will-it-reflow/ …more to be posted… 32
  • 33. 33 Optimizing Browser DOM Rendering Michael Labriola - @mlabriola Senior Consultant w/ Digital Primates

Notas do Editor

  1. Image licensed under creative commons attribution license. Found at http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/
  2. To combine these trees, the correct style needs to be computed for each element in the DOM tree. CSS styles are stored into various maps (buckets) so that they can be easily retrieved later. The mappings reduce the scope of the search, using the right most key of the selector.
  3. Image licensed under creative commons attribution license. Found at http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/This all matters for a simple reason. Manipulating the DOM is the slowest thing we can do in the web environment. Depending on what we do, the browser needs to mark things as invalid. The process of making them valid again means executing parts of this diagram.
  4. Image licensed under creative commons attribution license. Found at http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/
  5. Image licensed under creative commons attribution license. Found at http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/