SlideShare a Scribd company logo
Performance (Browser)
How browsers work?
● Rendering Engine (Webkit, Blink, Gecko)
● Javascript Engine (Nitro, V8, *monkey)
● Networking
● Persistence
Browser flow
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

Layout

Paint

● From hitting a URL to the usable web page
Loading Content
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

Layout

● HTTP Request
● DNS lookup, Data fetching, Server side
processing
● HTTP Response

Paint
Parsing HTML
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

Layout

Paint

● HTML is a serialized tree
● Grammatical parsing based
on doctype(DTD) or quirks
● Loading external files (JS,
CSS, Images)
● Creates content tree
● Done on adding HTML

http://dbaron.org/talks/2008-11-12-faster-html-andcss/slide-3.xhtml
Computing Style
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

Layout

Paint

● CSS selector matching
● Computed Stylesheet
● CSS parser
● Computes style for each
node
● Cascaded (Browser native
style, external, inline)
● Done on adding Styles

http://dbaron.org/talks/2008-11-12-faster-html-andcss/slide-8.xhtml
Construct Frames
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

Layout

Paint

● Create render tree
● Elements in render tree are
called frames or render
objects
● Tree has only displaying
elements
● Not one to one mapped to
content tree

http://dbaron.org/talks/2008-11-12-faster-html-andcss/slide-6.xhtml
Layout (Reflow)
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

Layout

● Laying out the elements using content tree, render
tree, computed styles
● Where to position the element wrt to the other
elements and how much space it will take
● Done when style or html changes lead to layout
changes

Paint
Paint (Repaint)
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

Layout

● Paints the layout on to the viewport using 2D
rendering api
● Tells GPU how to render the document
● Modern browsers use compositing and hardware
acceleration of GPU to provide faster paint cycles
● Done when layout, or styles changes and even on
scroll.

Paint
Optimizations
The way we write code can be used to optimize
each step the browser takes to build a
webpage and render it to user
Loading Content (Optimization)
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

Layout

● Minify scripts and CSS, make sprite images
● GZIP data from server
● Serve static content from cookieless domains, use
multiple domains for serving static content
● Reduce network round trips(Combine script,css,
images), Redirects
● Utilise browser caching to the max

Paint
Parse HTML (Optimization)
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

Layout

Paint

● Resources are loaded as the HTML is parsed
● Scripts are blocking in older browsers. (no document.
write)
● FOUC (Flash of unstyled content),no @import
● Use an optimized approach of having basic scripts to
show some state in the top of the page and rest of the
scripts (majority) at the bottom
Computing Style(Optimization)
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

Layout

Paint

● Specificity of selectors
● Parsed from right for each
node
● No inline styles
● Club dynamic style
changes into one (using a
className)

http://dbaron.org/talks/2008-11-12-faster-html-andcss/slide-8.xhtml
Construct Frames (Optimization)
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

● Frames are created only for visible items
● Visibility vs Display property

Layout

Paint
Layout(Optimization)
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

Layout

Paint

● Every time layout changes reflow is done.
● Can get really expensive because any change in any
element can result in complete reflow of the page.
● Avoid as much DOM manipulation as possible
● Club all DOM insertion into a single object
(DocumentFragment) and insert into dom once.
● DOM reflow happens even on querying layout properties
Paint(Optimization)
Load
Content

Parse
HTML

Compute
Style

Construct
Frames

Layout

Paint

● Minimise repaint in a page as much as possible
● Avoid changes while scrolling
● Try to use new CSS transform and animate rather than
modifying the elements top/left properties (Avoid jquery
animations as they cause both reflow and repaint)
● Don't over do optimization by trying to dispose of items
outside the viewport (Maybe faster in older browsers but can
make scrolling in most modern browsers slow)
Javascript Optimization
Scoping
● Scope variables and functions properly. Avoid using the global
namespace (use var statement)
● Global variables are the deepest in the scope chain
● with and try,catch add a level to scope chain
● Closure also add to a level in scope chain
Activation object
this
Scope Chain
Execution Context
0

window

arguments

[]

variables

undefined

Scope
1

Global
document

(object)

window

(object)
Javascript Optimization
Data Access
● Local variables and literals fastest
● Global variables are the deepest in the scope chain
● Accessing properties of objects and elements of array is more
expensive
● If a property is accessed in a loop more than once store it in a local
variable
Loops
● Avoid for each, for in, and other function based iterators as they
access all properties of the array object not just the elements
Demo
● http://codepen.io/paulirish/pen/nkwKs
vs
http://codepen.io/paulirish/pen/LsxyF

● Repaint demo : http://175.41.136.68:8090
Tools
● Chrome Dev Tools
● Pagespeed
● Yslow
● Fiddler
References
● How browsers work http://taligarsiel.
com/Projects/howbrowserswork1.htm
● Speed up Your Javascript : http://youtu.
be/mHtdZgou0qU
● Faster HTML and CSS: Layout Engine Internals for
Web Developers
be/a2_6bGNZ7bA

http://youtu.

More Related Content

What's hot (20)

PDF
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
Jumping Bean
 
PDF
Post-relational databases: What's wrong with web development?
Dobrica Pavlinušić
 
PPTX
Women Who Code, Ground Floor
Katie Weiss
 
PDF
Text classification With Rapid Miner
Chakrit Phain
 
PPTX
Mongodb open data day 2014
David Green
 
PPTX
Web Information Systems Html and css
Artificial Intelligence Institute at UofSC
 
KEY
Using NoSQL MongoDB with ColdFusion
indiver
 
PDF
RESTful with Drupal - in-s and out-s
Kalin Chernev
 
PDF
CosmosDb for beginners
Phil Pursglove
 
PPSX
Microsoft Hekaton
Siraj Memon
 
PDF
Mongo db3.0 wired_tiger_storage_engine
Kenny Gorman
 
PDF
React - The JavaScript Library for User Interfaces
Jumping Bean
 
PPTX
MongoDB
Rony Gregory
 
PDF
CBDW2014 - NoSQL Development With Couchbase and ColdFusion (CFML)
Ortus Solutions, Corp
 
PPTX
Web Information Systems XML
Artificial Intelligence Institute at UofSC
 
PPTX
Ruby onrails overview
Piyush Chand
 
PPTX
Web Development
Shivakrishna Gannu
 
PDF
Experiences with Evangelizing Java Within the Database
Marcelo Ochoa
 
PDF
Dotnet content
maheshcs1
 
PDF
ITB2016 - NoSQL with mongodb and ColdFusion (CFML)
Ortus Solutions, Corp
 
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
Jumping Bean
 
Post-relational databases: What's wrong with web development?
Dobrica Pavlinušić
 
Women Who Code, Ground Floor
Katie Weiss
 
Text classification With Rapid Miner
Chakrit Phain
 
Mongodb open data day 2014
David Green
 
Web Information Systems Html and css
Artificial Intelligence Institute at UofSC
 
Using NoSQL MongoDB with ColdFusion
indiver
 
RESTful with Drupal - in-s and out-s
Kalin Chernev
 
CosmosDb for beginners
Phil Pursglove
 
Microsoft Hekaton
Siraj Memon
 
Mongo db3.0 wired_tiger_storage_engine
Kenny Gorman
 
React - The JavaScript Library for User Interfaces
Jumping Bean
 
MongoDB
Rony Gregory
 
CBDW2014 - NoSQL Development With Couchbase and ColdFusion (CFML)
Ortus Solutions, Corp
 
Web Information Systems XML
Artificial Intelligence Institute at UofSC
 
Ruby onrails overview
Piyush Chand
 
Web Development
Shivakrishna Gannu
 
Experiences with Evangelizing Java Within the Database
Marcelo Ochoa
 
Dotnet content
maheshcs1
 
ITB2016 - NoSQL with mongodb and ColdFusion (CFML)
Ortus Solutions, Corp
 

Similar to Performance (browser) (20)

PDF
Neoito — How modern browsers work
Neoito
 
PPTX
Building high performing web pages
Nilesh Bafna
 
PDF
Ustream Techtalks: Google Chrome Developer Tools
Máté Nádasdi
 
PDF
You Can Work on the Web Patform! (GOSIM 2023)
Igalia
 
PDF
Building Real-World Dojo Web Applications
Andrew Ferrier
 
PDF
Dust.js
Yevgeniy Brikman
 
PPTX
WEB DEVELOPMENT.pptx
silvers5
 
PDF
Lit there be light
Ilya Gorenburg
 
PPTX
Best Practices with Sitecore
Anant Corporation
 
PPTX
web development
RamanDeep876641
 
PPTX
Dsc Charusat Learning React Part 1
JainamMehta19
 
PDF
Architektura html, css i javascript - Jan Kraus
Women in Technology Poland
 
PDF
HTML5 New Features and Resources
Ron Reiter
 
PDF
Html 5 - What's new?
Bethmi Gunasekara
 
PPTX
Browsers. Magic is inside.
Devexperts
 
PPTX
JavaScripts & jQuery
Asanka Indrajith
 
PDF
Intro JavaScript
koppenolski
 
ODP
Html5
prithag92
 
PPTX
025444215.pptx
RiyaJenner1
 
PDF
Mobile Browser Internal (Blink Rendering Engine)
Hyungwook Lee
 
Neoito — How modern browsers work
Neoito
 
Building high performing web pages
Nilesh Bafna
 
Ustream Techtalks: Google Chrome Developer Tools
Máté Nádasdi
 
You Can Work on the Web Patform! (GOSIM 2023)
Igalia
 
Building Real-World Dojo Web Applications
Andrew Ferrier
 
WEB DEVELOPMENT.pptx
silvers5
 
Lit there be light
Ilya Gorenburg
 
Best Practices with Sitecore
Anant Corporation
 
web development
RamanDeep876641
 
Dsc Charusat Learning React Part 1
JainamMehta19
 
Architektura html, css i javascript - Jan Kraus
Women in Technology Poland
 
HTML5 New Features and Resources
Ron Reiter
 
Html 5 - What's new?
Bethmi Gunasekara
 
Browsers. Magic is inside.
Devexperts
 
JavaScripts & jQuery
Asanka Indrajith
 
Intro JavaScript
koppenolski
 
Html5
prithag92
 
025444215.pptx
RiyaJenner1
 
Mobile Browser Internal (Blink Rendering Engine)
Hyungwook Lee
 
Ad

Recently uploaded (20)

PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Python basic programing language for automation
DanialHabibi2
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Ad

Performance (browser)