SlideShare a Scribd company logo
1 of 53
Performance-driven front-end development
2013-10-25
By Zhang Hongliang
Online slide show
Raxtone
Concepts
•
•

•
•

Layout is the process by which Chrome calculates the positions and
sizes of all the elements on the page.
Reflow (aka layout thrashing )is the name of the web browser process
for re-calculating the positions and geometries of elements in the
document, for the purpose of re-rendering part or all of the document.
A repaint occurs when changes are made to an elements skin that
changes visibility, but do not affect its layout.
A web browser engine, (sometimes called layout engine or rendering
engine), is a software component that takes marked up content (such
as HTML, XML, image files, etc.) and formatting information (such as
CSS, XSL, etc.) and displays the formatted content on the screen.
– Main engine
Raxtone
Raxtone
Main engine

Raxtone
Sources
• Tools
– Canary or chrome
• Open a Chrome window in incognito
mode(ctrl+shift+n)
– Devtools
– Pagespeed insights
• Links( slash not omitted )
– http://testwww.flynavi.cn/help/
– http://testwww.flynavi.cn/
– http://testwww.flynavi.cn/webflynavi/navi.htm
Raxtone
Problems

Performance Tooling by Paul Irish
(#perfmatters at SFHTML5)
YouTube
Raxtone
slide
Page load
• The DOMContentLoaded event is fired when the
document has been completely loaded and parsed,
without waiting for stylesheets, images, and
subframes to finish loading (the load event can be
used to detect a fully-loaded page).
• The load event is fired when a resource and its
dependent resources have finished loading.

Raxtone
External cause
Region
Platform
Network

GTmetrix
Raxtone
User perception

Raxtone
Ideal situation

Raxtone
Current situation
• The study found that the median load time
for first-time visitors to a retail website’s
home page was 7.25 seconds
• 57% of online shoppers will wait 3 seconds
or less before abandoning the site.
• based the 3 seconds ideal load time on pc
(source:PhoCusWright/Akamai report)
Raxtone
Page load time
Chrome(Canary): Devtools – Network
(open Devtools and refresh)

Raxtone
Network waterfall
•

resources in the Network table are sorted by the start time of each
request (the network "waterfall").
– the request's latency and receipt time are displayed above the
corresponding bar's light- and dark-shaded areas, respectively

Raxtone
Solution - methods
Sprite,combine

•Missing Trailing Slash
•Connecting Web Sites

Including css,html

Common module

$.ajax cache default
Raxtone
Solution - tool
• Use PageSpeed Insights to identify
performance best practices that can be
applied to your site, and PageSpeed
optimization tools to automate the process
of applying those best practices.

Raxtone
PageSpeed Insights
• Best Practice(help page)

S sprite

Raxtone
PageSpeed Insights
• Before building

Grunt tasks:
Concat
Cssmin
uglify
htmlmin
imagemin
Raxtone
PageSpeed Insights
• After building (suggestion config by server
client)

Raxtone
Image assets
• Pc portal flynavi.cn

Raxtone
Solution
• grunt-contrib-imagemin
– Minify PNG and JPEG images

Raxtone
Non-blocking delivery
• Limiting yourself to downloading a single
large JavaScript file will only result in
locking the browser out for a long period of
time, despite it being just one HTTP
request.

Raxtone
Solution
• The secret to nonblocking scripts is to load
the JavaScript source code after the page
has finished loading.
–
–
–
–
–

Asynchronous
Script Positioning
Deferred Scripts
Requirejs
Jquery.lazyload
Raxtone
Critical path css
• External CSS stylesheets are renderblocking, meaning the browser won’t paint
content to the screen until all of your CSS –
specifically, media=’screen’ CSS – arrives.
– Source:
Detecting Critical CSS For Above-the-Fold Content

Raxtone
Solution
• Prioritize visible content
– one (and only one) external CSS file
– an inlined CSS block that is page specific and
allows your above the fold content to load
immediately.

Raxtone
@font-face load
• 1) custom fonts are awesome and we want
to use them
• 2) custom fonts slow down our pages by
being large additional resources.

Raxtone
Solution
• Only load on large screens
• Ajax in the fonts
• Lazy load the fonts, load on subsequent
page loads after cached
– Source:
Preventing the Performance Hit from Custom Fonts

Raxtone
Runtime
• Run time (program lifecycle phase)
– In computer science, run time, run-time,
runtime, or execution time is the time during
which a program is running (executing), in
contrast to other phases of a program's lifecycle
such as compile time, link time, load time, etc.

Raxtone
Interation
• Human–computer interaction
– Human–computer interaction (HCI) involves
the study, planning, and design of the
interaction between people (users) and
computers.

Raxtone
Transitions & animations
• The CSS transition property is a shorthand property for
transition-property, transition-duration, transition-timingfunction, and transition-delay. It allows to define the
transition between two states of an element. Different
states may be defined using pseudo-classes like :hover
or :active or dynamically set using JavaScript.
• The animation CSS property is a shorthand property for
animation-name, animation-duration, animation-timingfunction, animation-delay, animation-iteration-count and
animation-direction.
Raxtone
Solution

Raxtone
Example 1 - 1
• Source: flynavi project
• Tool: devtools -

Raxtone
Example 1 - 2
Show composited layer borders: It can indicate the rendered
elements which may be animating or have CSS transforms/
transitions applied to them that change the shape or positioning
of the element.

Raxtone
Example 1 - 3
• Applying transform style

Raxtone
Example 1 - 4
• Enable continuous page repainting
– This is a tool that helps you identify elements
on the page which are costly. The page will
continuously repaint, showing a counter of how
much painting work is happening.
– Paint hurts on low-end devices

Raxtone
Example 1 - 5

Raxtone
Scrolling
• Scrolling areas are used to let the user move
text and/or images across the device's
display.

Raxtone
Memory leak & GC
•

•

•

A memory leak is a gradual loss of available computer memory. It occurs
when a program repeatedly fails to return memory it has obtained for
temporary use. JavaScript web apps can often suffer from similar memory
related issues that native applications do, such as leaks and bloat but they also
have to deal with garbage collection pauses.
In computer science, garbage collection (GC) is a form of automatic memory
management. The garbage collector, or just collector, attempts to reclaim
garbage, or memory occupied by objects that are no longer in use by the
program.
Problem:
– Is my page using too much memory?
– Is my page free of memory leaks?
– How frequently is my page forcing
garbage collection?
Raxtone
Key point - layout thrashing
• Outside of initial page load problems,
“layout thrashing” is the most common
performance problem in dynamic web
applications. This is particularly true for
Single Page Applications which build and
destroy views on the fly.

Raxtone
Solution - Minimize reflow
• Reduce unnecessary DOM depth. Changes at one level in
the DOM tree can cause changes at every level of the tree all the way up to the root, and all the way down into the
children of the modified node.
• Minimize CSS rules, and remove unused CSS rules.
• If you make complex rendering changes such as
animations, do so out of the flow. Use position-absolute or
position-fixed to accomplish this.
• Avoid unnecessary complex CSS selectors - descendant
selectors in particular - which require more CPU power to
do selector matching.
Raxtone
What causes the browser to
layout?
innerHTML

Raxtone
RequestAnimationFrame
• The window.requestAnimationFrame()
method tells the browser that you wish to
perform an animation and requests that the
browser call a specified function to update
an animation before the next repaint. The
method takes as an argument a callback to
be invoked before the repaint.
Raxtone
The basic tools
• The workbench becomes the center of the
wood shop, the craftsman returning to it
time and time again as a piece takes shape.
-- The pragmatic programmer by Andrew
Hunt David Thomas

Raxtone
Devtools
• Devtools – Timeline

Raxtone
Libraries
• FastDom
– Target
» Eliminates layout thrashing by batching DOM read/write
operations
– Principle
» Each read/write job is added to a corresponding read/write
queue. The queues are emptied (reads, then writes) at the
turn of the next frame using
window.requestAnimationFrame.

Raxtone
Example 1
• The code shared on jsfiddle.
– Move a div element

Raxtone
Example 2
• Positioning button animation(flynavi project)

Raxtone

var position_interval = null;
void function () {
var num = 0 ,interval=200, preFrameTime=0
position_interval = requestAnimationFrame(function (stampTime) {
var duration = stampTime - preFrameTime;
if(duration< interval){
requestAnimationFrame(arguments.callee)
return
}
/* 填加自车位置后,隐藏正在定位按钮样式 */
if (mapHandler.mapObj && mapHandler.curMarker) {
positionStateEnd();
return;
}
preFrameTime=stampTime
…
Example 3 - 1
• 3,innerText leading to layout

Raxtone
Example 3 - 2
•

Before modified

$('#normal_withTime_one').text(util_common.formatMinute(Math.round(newVal.timeExtend10/60)));
$('#normal_withTime_two').text(util_common.formatMinute(Math.round(newVal.timeExtend20/60)));

After modified
fastdom.write(function () {
$('#normal_withTime_one').text(util_common.formatMinute(Math.round(newVal.timeExtend10 / 60)));
$('#normal_withTime_two').text(util_common.formatMinute(Math.round(newVal.timeExtend20 / 60)));

})

Raxtone
Example 4
• Comprehensive use: coffeescript, requirejs,
fastdom, javascriptmvc, RWD, refactor
define(['fastdom','jquerymx'] ,(fastdom)->
$.Model('MapRouteView',
{
setUi: ->
$path_info = $('#path_info')
fastdom.read(->
top1 = $path_info.position().top - 57
top2 = $path_info.position().top - 94
fastdom.write(->
$('#zoom_out').css('top', top1);
$('#zoom_in').css('top', top2);
$('#tmc_btn').hide();
$('#navi').hide("fast", ->
$path_info.css({'visibility':
'visible'})
)
)
)
}
)
)

Raxtone

require(['mapRouteView'],function(){
setMapRouteView = new MapRouteView(config);
setMapRouteView.displayData();
})
Qualification

Raxtone
Todo
• Turn on pain rects, layer borders, continuous
repainting
• about:tracing
• bootstrap
• Css lib
– Topcoat
• Tool
– speed curve
– WebPageTest
Raxtone
Thanks
•
•
•
•
•

@twitter
@paul_irish
@ChromiumDev
@YouTube
Other internet resources

Raxtone
Raxtone

More Related Content

Viewers also liked (19)

Free Software - Persian Edition
Free Software - Persian EditionFree Software - Persian Edition
Free Software - Persian Edition
 
STC PMC Newsletter 2008-04
STC PMC Newsletter 2008-04STC PMC Newsletter 2008-04
STC PMC Newsletter 2008-04
 
STC PMC Newsletter 2011-01
STC PMC Newsletter 2011-01STC PMC Newsletter 2011-01
STC PMC Newsletter 2011-01
 
Paginas para publicar informacion
Paginas para publicar informacionPaginas para publicar informacion
Paginas para publicar informacion
 
Amazing Thailand+The Queen Projects+ป.2+126+dltvengp2+55t2eng p02 f21-4page
Amazing Thailand+The Queen Projects+ป.2+126+dltvengp2+55t2eng p02 f21-4pageAmazing Thailand+The Queen Projects+ป.2+126+dltvengp2+55t2eng p02 f21-4page
Amazing Thailand+The Queen Projects+ป.2+126+dltvengp2+55t2eng p02 f21-4page
 
Poetry/Influence
Poetry/InfluencePoetry/Influence
Poetry/Influence
 
Autobiografía Lineal
Autobiografía LinealAutobiografía Lineal
Autobiografía Lineal
 
STC PMC Newsletter 2005-03
STC PMC Newsletter 2005-03STC PMC Newsletter 2005-03
STC PMC Newsletter 2005-03
 
Tics 4
Tics 4Tics 4
Tics 4
 
trabajo
trabajotrabajo
trabajo
 
Prezentatsiya do uroku
Prezentatsiya do urokuPrezentatsiya do uroku
Prezentatsiya do uroku
 
STC PMC Newsletter 2011-03
STC PMC Newsletter 2011-03STC PMC Newsletter 2011-03
STC PMC Newsletter 2011-03
 
Portal dos Bandeirantes De Salto
Portal dos Bandeirantes De SaltoPortal dos Bandeirantes De Salto
Portal dos Bandeirantes De Salto
 
STC PMC Newsletter 2009-01
STC PMC Newsletter 2009-01STC PMC Newsletter 2009-01
STC PMC Newsletter 2009-01
 
STC PMC Newsletter 2011-02
STC PMC Newsletter 2011-02STC PMC Newsletter 2011-02
STC PMC Newsletter 2011-02
 
2º basico a 20 de noviembre
2º basico a  20 de noviembre2º basico a  20 de noviembre
2º basico a 20 de noviembre
 
ใบงานที่ 2
ใบงานที่ 2ใบงานที่ 2
ใบงานที่ 2
 
Ci 350 character education
Ci 350 character educationCi 350 character education
Ci 350 character education
 
Партологія
Партологія Партологія
Партологія
 

Similar to Performance-driven front-end development

Building high performing web pages
Building high performing web pagesBuilding high performing web pages
Building high performing web pagesNilesh Bafna
 
PrairieDevCon 2014 - Web Doesn't Mean Slow
PrairieDevCon 2014 -  Web Doesn't Mean SlowPrairieDevCon 2014 -  Web Doesn't Mean Slow
PrairieDevCon 2014 - Web Doesn't Mean Slowdmethvin
 
An Introduction to Pagespeed Optimisation
An Introduction to Pagespeed OptimisationAn Introduction to Pagespeed Optimisation
An Introduction to Pagespeed OptimisationPratyush Majumdar
 
TSSJS2010 Presenatation on: Performance Anti Patterns In Ajax Applications
TSSJS2010 Presenatation on: Performance Anti Patterns In Ajax ApplicationsTSSJS2010 Presenatation on: Performance Anti Patterns In Ajax Applications
TSSJS2010 Presenatation on: Performance Anti Patterns In Ajax Applicationsguestc75cdc
 
Performance anti patterns in ajax applications
Performance anti patterns in ajax applicationsPerformance anti patterns in ajax applications
Performance anti patterns in ajax applicationsSergeyChernyshev
 
Asynchronous javascript and xml
Asynchronous javascript and xmlAsynchronous javascript and xml
Asynchronous javascript and xmlBui Kiet
 
Group meeting: Polaris - Faster Page Loads Using Fine-grained Dependency Trac...
Group meeting: Polaris - Faster Page Loads Using Fine-grained Dependency Trac...Group meeting: Polaris - Faster Page Loads Using Fine-grained Dependency Trac...
Group meeting: Polaris - Faster Page Loads Using Fine-grained Dependency Trac...Yu-Hsin Hung
 
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...Amazon Web Services
 
Automating your plugin with WP-Cron
Automating your plugin with WP-CronAutomating your plugin with WP-Cron
Automating your plugin with WP-CronDan Cannon
 
Tool it Up! - Session #2 - NetPanel
Tool it Up! - Session #2 - NetPanelTool it Up! - Session #2 - NetPanel
Tool it Up! - Session #2 - NetPaneltoolitup
 
From Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceFrom Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceSebastian Springer
 
Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?) Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?) SOASTA
 
Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)
Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)
Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)Cliff Crocker
 

Similar to Performance-driven front-end development (20)

Salesforce Performance hacks - Client Side
Salesforce Performance hacks - Client SideSalesforce Performance hacks - Client Side
Salesforce Performance hacks - Client Side
 
#Webperf Choreography
#Webperf Choreography#Webperf Choreography
#Webperf Choreography
 
Building high performing web pages
Building high performing web pagesBuilding high performing web pages
Building high performing web pages
 
PrairieDevCon 2014 - Web Doesn't Mean Slow
PrairieDevCon 2014 -  Web Doesn't Mean SlowPrairieDevCon 2014 -  Web Doesn't Mean Slow
PrairieDevCon 2014 - Web Doesn't Mean Slow
 
An Introduction to Pagespeed Optimisation
An Introduction to Pagespeed OptimisationAn Introduction to Pagespeed Optimisation
An Introduction to Pagespeed Optimisation
 
TSSJS2010 Presenatation on: Performance Anti Patterns In Ajax Applications
TSSJS2010 Presenatation on: Performance Anti Patterns In Ajax ApplicationsTSSJS2010 Presenatation on: Performance Anti Patterns In Ajax Applications
TSSJS2010 Presenatation on: Performance Anti Patterns In Ajax Applications
 
Performance anti patterns in ajax applications
Performance anti patterns in ajax applicationsPerformance anti patterns in ajax applications
Performance anti patterns in ajax applications
 
performance.ppt
performance.pptperformance.ppt
performance.ppt
 
Asynchronous javascript and xml
Asynchronous javascript and xmlAsynchronous javascript and xml
Asynchronous javascript and xml
 
Remix
RemixRemix
Remix
 
Group meeting: Polaris - Faster Page Loads Using Fine-grained Dependency Trac...
Group meeting: Polaris - Faster Page Loads Using Fine-grained Dependency Trac...Group meeting: Polaris - Faster Page Loads Using Fine-grained Dependency Trac...
Group meeting: Polaris - Faster Page Loads Using Fine-grained Dependency Trac...
 
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
 
Automating your plugin with WP-Cron
Automating your plugin with WP-CronAutomating your plugin with WP-Cron
Automating your plugin with WP-Cron
 
Performance on a budget
Performance on a budgetPerformance on a budget
Performance on a budget
 
Tool it Up! - Session #2 - NetPanel
Tool it Up! - Session #2 - NetPanelTool it Up! - Session #2 - NetPanel
Tool it Up! - Session #2 - NetPanel
 
From Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceFrom Zero to Hero – Web Performance
From Zero to Hero – Web Performance
 
Transforming the web into a real application platform
Transforming the web into a real application platformTransforming the web into a real application platform
Transforming the web into a real application platform
 
Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?) Metrics, metrics everywhere (but where the heck do you start?)
Metrics, metrics everywhere (but where the heck do you start?)
 
Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)
Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)
Velocity NYC: Metrics, metrics everywhere (but where the heck do you start?)
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 

Recently uploaded

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
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
 
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
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
[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
 
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
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 

Recently uploaded (20)

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
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
 
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
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
[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
 
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
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 

Performance-driven front-end development

  • 1. Performance-driven front-end development 2013-10-25 By Zhang Hongliang Online slide show Raxtone
  • 2. Concepts • • • • Layout is the process by which Chrome calculates the positions and sizes of all the elements on the page. Reflow (aka layout thrashing )is the name of the web browser process for re-calculating the positions and geometries of elements in the document, for the purpose of re-rendering part or all of the document. A repaint occurs when changes are made to an elements skin that changes visibility, but do not affect its layout. A web browser engine, (sometimes called layout engine or rendering engine), is a software component that takes marked up content (such as HTML, XML, image files, etc.) and formatting information (such as CSS, XSL, etc.) and displays the formatted content on the screen. – Main engine Raxtone
  • 5. Sources • Tools – Canary or chrome • Open a Chrome window in incognito mode(ctrl+shift+n) – Devtools – Pagespeed insights • Links( slash not omitted ) – http://testwww.flynavi.cn/help/ – http://testwww.flynavi.cn/ – http://testwww.flynavi.cn/webflynavi/navi.htm Raxtone
  • 6. Problems Performance Tooling by Paul Irish (#perfmatters at SFHTML5) YouTube Raxtone slide
  • 7. Page load • The DOMContentLoaded event is fired when the document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading (the load event can be used to detect a fully-loaded page). • The load event is fired when a resource and its dependent resources have finished loading. Raxtone
  • 11. Current situation • The study found that the median load time for first-time visitors to a retail website’s home page was 7.25 seconds • 57% of online shoppers will wait 3 seconds or less before abandoning the site. • based the 3 seconds ideal load time on pc (source:PhoCusWright/Akamai report) Raxtone
  • 12. Page load time Chrome(Canary): Devtools – Network (open Devtools and refresh) Raxtone
  • 13. Network waterfall • resources in the Network table are sorted by the start time of each request (the network "waterfall"). – the request's latency and receipt time are displayed above the corresponding bar's light- and dark-shaded areas, respectively Raxtone
  • 14. Solution - methods Sprite,combine •Missing Trailing Slash •Connecting Web Sites Including css,html Common module $.ajax cache default Raxtone
  • 15. Solution - tool • Use PageSpeed Insights to identify performance best practices that can be applied to your site, and PageSpeed optimization tools to automate the process of applying those best practices. Raxtone
  • 16. PageSpeed Insights • Best Practice(help page) S sprite Raxtone
  • 17. PageSpeed Insights • Before building Grunt tasks: Concat Cssmin uglify htmlmin imagemin Raxtone
  • 18. PageSpeed Insights • After building (suggestion config by server client) Raxtone
  • 19. Image assets • Pc portal flynavi.cn Raxtone
  • 20. Solution • grunt-contrib-imagemin – Minify PNG and JPEG images Raxtone
  • 21. Non-blocking delivery • Limiting yourself to downloading a single large JavaScript file will only result in locking the browser out for a long period of time, despite it being just one HTTP request. Raxtone
  • 22. Solution • The secret to nonblocking scripts is to load the JavaScript source code after the page has finished loading. – – – – – Asynchronous Script Positioning Deferred Scripts Requirejs Jquery.lazyload Raxtone
  • 23. Critical path css • External CSS stylesheets are renderblocking, meaning the browser won’t paint content to the screen until all of your CSS – specifically, media=’screen’ CSS – arrives. – Source: Detecting Critical CSS For Above-the-Fold Content Raxtone
  • 24. Solution • Prioritize visible content – one (and only one) external CSS file – an inlined CSS block that is page specific and allows your above the fold content to load immediately. Raxtone
  • 25. @font-face load • 1) custom fonts are awesome and we want to use them • 2) custom fonts slow down our pages by being large additional resources. Raxtone
  • 26. Solution • Only load on large screens • Ajax in the fonts • Lazy load the fonts, load on subsequent page loads after cached – Source: Preventing the Performance Hit from Custom Fonts Raxtone
  • 27. Runtime • Run time (program lifecycle phase) – In computer science, run time, run-time, runtime, or execution time is the time during which a program is running (executing), in contrast to other phases of a program's lifecycle such as compile time, link time, load time, etc. Raxtone
  • 28. Interation • Human–computer interaction – Human–computer interaction (HCI) involves the study, planning, and design of the interaction between people (users) and computers. Raxtone
  • 29. Transitions & animations • The CSS transition property is a shorthand property for transition-property, transition-duration, transition-timingfunction, and transition-delay. It allows to define the transition between two states of an element. Different states may be defined using pseudo-classes like :hover or :active or dynamically set using JavaScript. • The animation CSS property is a shorthand property for animation-name, animation-duration, animation-timingfunction, animation-delay, animation-iteration-count and animation-direction. Raxtone
  • 31. Example 1 - 1 • Source: flynavi project • Tool: devtools - Raxtone
  • 32. Example 1 - 2 Show composited layer borders: It can indicate the rendered elements which may be animating or have CSS transforms/ transitions applied to them that change the shape or positioning of the element. Raxtone
  • 33. Example 1 - 3 • Applying transform style Raxtone
  • 34. Example 1 - 4 • Enable continuous page repainting – This is a tool that helps you identify elements on the page which are costly. The page will continuously repaint, showing a counter of how much painting work is happening. – Paint hurts on low-end devices Raxtone
  • 35. Example 1 - 5 Raxtone
  • 36. Scrolling • Scrolling areas are used to let the user move text and/or images across the device's display. Raxtone
  • 37. Memory leak & GC • • • A memory leak is a gradual loss of available computer memory. It occurs when a program repeatedly fails to return memory it has obtained for temporary use. JavaScript web apps can often suffer from similar memory related issues that native applications do, such as leaks and bloat but they also have to deal with garbage collection pauses. In computer science, garbage collection (GC) is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program. Problem: – Is my page using too much memory? – Is my page free of memory leaks? – How frequently is my page forcing garbage collection? Raxtone
  • 38. Key point - layout thrashing • Outside of initial page load problems, “layout thrashing” is the most common performance problem in dynamic web applications. This is particularly true for Single Page Applications which build and destroy views on the fly. Raxtone
  • 39. Solution - Minimize reflow • Reduce unnecessary DOM depth. Changes at one level in the DOM tree can cause changes at every level of the tree all the way up to the root, and all the way down into the children of the modified node. • Minimize CSS rules, and remove unused CSS rules. • If you make complex rendering changes such as animations, do so out of the flow. Use position-absolute or position-fixed to accomplish this. • Avoid unnecessary complex CSS selectors - descendant selectors in particular - which require more CPU power to do selector matching. Raxtone
  • 40. What causes the browser to layout? innerHTML Raxtone
  • 41. RequestAnimationFrame • The window.requestAnimationFrame() method tells the browser that you wish to perform an animation and requests that the browser call a specified function to update an animation before the next repaint. The method takes as an argument a callback to be invoked before the repaint. Raxtone
  • 42. The basic tools • The workbench becomes the center of the wood shop, the craftsman returning to it time and time again as a piece takes shape. -- The pragmatic programmer by Andrew Hunt David Thomas Raxtone
  • 43. Devtools • Devtools – Timeline Raxtone
  • 44. Libraries • FastDom – Target » Eliminates layout thrashing by batching DOM read/write operations – Principle » Each read/write job is added to a corresponding read/write queue. The queues are emptied (reads, then writes) at the turn of the next frame using window.requestAnimationFrame. Raxtone
  • 45. Example 1 • The code shared on jsfiddle. – Move a div element Raxtone
  • 46. Example 2 • Positioning button animation(flynavi project) Raxtone var position_interval = null; void function () { var num = 0 ,interval=200, preFrameTime=0 position_interval = requestAnimationFrame(function (stampTime) { var duration = stampTime - preFrameTime; if(duration< interval){ requestAnimationFrame(arguments.callee) return } /* 填加自车位置后,隐藏正在定位按钮样式 */ if (mapHandler.mapObj && mapHandler.curMarker) { positionStateEnd(); return; } preFrameTime=stampTime …
  • 47. Example 3 - 1 • 3,innerText leading to layout Raxtone
  • 48. Example 3 - 2 • Before modified $('#normal_withTime_one').text(util_common.formatMinute(Math.round(newVal.timeExtend10/60))); $('#normal_withTime_two').text(util_common.formatMinute(Math.round(newVal.timeExtend20/60))); After modified fastdom.write(function () { $('#normal_withTime_one').text(util_common.formatMinute(Math.round(newVal.timeExtend10 / 60))); $('#normal_withTime_two').text(util_common.formatMinute(Math.round(newVal.timeExtend20 / 60))); }) Raxtone
  • 49. Example 4 • Comprehensive use: coffeescript, requirejs, fastdom, javascriptmvc, RWD, refactor define(['fastdom','jquerymx'] ,(fastdom)-> $.Model('MapRouteView', { setUi: -> $path_info = $('#path_info') fastdom.read(-> top1 = $path_info.position().top - 57 top2 = $path_info.position().top - 94 fastdom.write(-> $('#zoom_out').css('top', top1); $('#zoom_in').css('top', top2); $('#tmc_btn').hide(); $('#navi').hide("fast", -> $path_info.css({'visibility': 'visible'}) ) ) ) } ) ) Raxtone require(['mapRouteView'],function(){ setMapRouteView = new MapRouteView(config); setMapRouteView.displayData(); })
  • 51. Todo • Turn on pain rects, layer borders, continuous repainting • about:tracing • bootstrap • Css lib – Topcoat • Tool – speed curve – WebPageTest Raxtone