SlideShare una empresa de Scribd logo
1 de 29
Performance Best Practices - Part 1 -
Client Side [JS, CSS, HTML, jQuery]
Presenter: Sathyan, Mindfire Solutions
Date: 03rd Sep 2013
Image Source: http://www.webperformancetoday.com/2011/06/30/revisiting-the-
performance-equation/ Presenter: Sathyan, Mindfire Solutions
Presenter: Sathyan, Mindfire Solutions
 Average Frontend time is 75% and above
 No inline JavaScript
 No Inline Styles
 Refer only the necessary include [js, css, etc.]
files for the page
 Always remove code, DOM, CSS that you do
not need – Sample
 Minimal comments, comment only what the
code does and not how!
 Use JSON
 Less less less
Presenter: Sathyan, Mindfire Solutions
 Minimize HTTP Requests
 Put Stylesheets at the Top
 Put Scripts at the Bottom
 Avoid Redirects
 Make Ajax Cacheable
 Use GET for AJAX Requests
 Post-load Components
 Preload Components
 Reduce the Number of DOM Elements
Presenter: Sathyan, Mindfire Solutions
 JAX
 What?
 Really?
 AJAX Control Toolkit
 But I need It…
 Callback
 Read
 See
Presenter: Sathyan, Mindfire Solutions
Presenter: Sathyan, Mindfire Solutions
 CSS Sprites
 http://www.websiteoptimization.com/speed/
tweak/css-sprites/
 Replace graphic rollovers with CSS rollovers
 colored backgrounds, borders, or spacing
instead of graphic techniques
 Replace graphic text headers with CSS text
headers
Presenter: Sathyan, Mindfire Solutions
 Use efficient CSS selectors
◦ Right to left $(“body #container div a”)
◦ Rules with descendants body * {...}.hide-scrollbars * {...}
◦ Rules with child or adjacent selectors body > * {...}.hide-
scrollbars * {...}
◦ Rules with overly qualified selectors – IDs with tags
◦ Remove redundant qualifiers.
 Avoid CSS expressions [ IE 5 – 7]
 Put CSS in the document head
 Specify image dimensions
 Specify a character set
Presenter: Sathyan, Mindfire Solutions
 CSS 3 ?
 Group Similar Styles
 Reduce No of line breaks
 Simple colors #333333, #DDDDDD, #112255, #AABBCC, #FF0000
to #333, #DDD, #125, #ABC, #F00
 Remove “px”
 Images
Presenter: Sathyan, Mindfire Solutions
 Scroll, Resize 
 Chrome Developer Tools – Profiles – flipkart
 CSS Stress Test
 Chrome Developer Tools – Timeline Ctrl E R
flipkart
 Chrome Developer Tools –Audit
Presenter: Sathyan, Mindfire Solutions
 Native JS Code
 Grouping
 Reuse
 Caching
 Refer an element as directly as possible using
the ID selector rather than using search/find
in a container, yes that is right, because it
translates directly to good old
getElementByID()
 Concat with Array.prototype.join() – Really?
 Data Structures Push() pop() Shift() - Read
 Use ‘this’
 Switch it!
 Loops $.each() Vs Native
 Initializing instance variables
 Know your Closures
 Cache – $(".someelement") -- Assign to a Var!
Presenter: Sathyan, Mindfire Solutions
Presenter: Sathyan, Mindfire Solutions
 Always Unbind before binding
 Most abused part
 Leads to repeated calls
 Repeated requests leads to pathetic web page
 See
 DOM Manipulation is BAD
for (var ct=0; ct <1000; ++ct)
{
$("#header").html($("#header").html() + ‘something from resultset’);
}
should be written as:
var fullHeaderContent = $("#header").html();
for (var ct=0; ct <1000; ++ct)
{
fullHeaderContent += ‘something from resultset’;
}
$("#header").html(fullHeaderContent );
Presenter: Sathyan, Mindfire Solutions
//BAD
for (var ctPatient=0; ctPatient<=rows.length; ++ctPatient)
{
$('#alertResult').append('<tr><td>'+rows[ctPatient]+'</td></tr>');
}
// AWESOME
var domTree = '';
for (var ctPatient=0; ctPatient<=rows.length; ++ctPatient)
{
domTree += '<tr><td>'+rows[ctPatient]+'</td></tr>';
}
$('#alertResult').append(domTree);
Presenter: Sathyan, Mindfire Solutions
Presenter: Sathyan, Mindfire Solutions
 Avoid using pseudo and attribute selectors
◦ $(‘:visible, :hidden’); $(’[attribute=value]’);
 Class Selectors Next Slower [IE9]
 Tags!
 ID ID ID ID
 Chaining – Multi Selectors
 Sizzle
 Depth of call stack
 Rapid fire rounds – 2 to 3 milliseconds
 Even bubbling – Super Post
 Mouseup Vs Click
Presenter: Sathyan, Mindfire Solutions
$("#longlist li").on("mouseenter", function() { $(this).text("Click
me!");
});
$("#longlist li").on("click", function() { $(this).text("Why did you click
me?!");
});
var list = $("#longlist");
list.on("mouseenter", "li", function(){
$(this).text("Click me!");
});
list.on("click", "li", function() {
$(this).text("Why did you click me?!");
});
http://gregfranko.com/jquery-best-practices/#/20
 Hello World!
 Why?
 Options?
 Window Events?
Presenter: Sathyan, Mindfire Solutions
 It matters
 The latest is the greatest, always
Presenter: Sathyan, Mindfire Solutions
 The best Javascript debugger out there!
 Console shows warning, errors, info
 Look for Yellow and Red – If you see them,
they are bad, get rid of those warnings, errors
right away!
 Do you see 404? Bad, Very Bad, Please act on
it
 Are there repeated calls? No use of “stressing”
the point here, get rid of duplicate calls.
 Net Tab – Wait time - receive time
Presenter: Sathyan, Mindfire Solutions
 Asynch Calls for Wait time
 Number of requests – can they be reduced?
Are there repeated calls? Where is the most
time spent?
 Categorize the bottlenecks using the waterfall
charts
 console.profile, console.time and other
Console APIs are very powerful, learn and use
http://getfirebug.com/wiki/index.php/Conso
le_API
Presenter: Sathyan, Mindfire Solutions
 Yslow
◦ Use a Content Delivery Network (CDN)
◦ Add Expires headers
◦ Avoid empty src or href
◦ Compress components with gzip
◦ Configure entity tags (ETags)
◦ Make favicon small and cacheable
◦ Minification
◦ Bundling
◦ One Big JS/CSS
Presenter: Sathyan, Mindfire Solutions
 uniform way to analyze and report on the
degree to which measured performance
meets user expectations.
 Set Your Apdex Score
 Et Your Apdex Score
Presenter: Sathyan, Mindfire Solutions
 Chrome Developer Tools – Audit
 Miniprofiler
 Glimpse
 Firebug - Network
 Yslow
 PageSpeed
 Newrelic
 http://www.webpagetest.org/
 https://code.google.com/p/leak-finder-for-
javascript/
Presenter: Sathyan, Mindfire Solutions
Presenter: Sathyan, Mindfire Solutions
Presenter: Sathyan, Mindfire Solutions
 http://www.stevesouders.com
 http://www.websiteoptimization.com/
 http://www.webpagetest.org/
 http://webdevchecklist.com/asp.net/performance/
 http://www.strangeloopnetworks.com/assets/images/visualizing_web_performance_pos
ter.jpg
 https://developers.google.com/speed/pagespeed/?csw=1
 https://developers.google.com/speed/docs/best-practices/rendering
 http://oreilly.com/server-administration/excerpts/even-faster-websites/writing-
efficient-javascript.html
 http://gregfranko.com/jquery-best-practices/#/
 http://www.artzstudio.com/2009/04/jquery-performance-rules/
 http://vimeo.com/43659068
 http://addyosmani.com/blog/
 http://www.webperformancetoday.com/2010/07/09/waterfalls-101/
Presenter: Sathyan, Mindfire Solutions
Question and Answer
 HTML5?
 Local Storage?
 Web Sockets?
 http://phantomjs.org/
 Node.js
 Backbone.js
Presenter: Sathyan, Mindfire Solutions
Thank you

Más contenido relacionado

Similar a Performance Best Practices - Part 1 - Client Side [JS, CSS, HTML, jQuery]

AtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
AtlasCamp 2011 - Five Strategies to Accelerate Plugin DevelopmentAtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
AtlasCamp 2011 - Five Strategies to Accelerate Plugin Developmentmrdon
 
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP MeetupWeb Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP MeetupJonathan Klein
 
Introduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopIntroduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopMark Rackley
 
3 Tips to Deliver Fast Performance Across Mobile Web
3 Tips to Deliver Fast Performance Across Mobile Web3 Tips to Deliver Fast Performance Across Mobile Web
3 Tips to Deliver Fast Performance Across Mobile WebDynatrace
 
Sinatra and JSONQuery Web Service
Sinatra and JSONQuery Web ServiceSinatra and JSONQuery Web Service
Sinatra and JSONQuery Web Servicevvatikiotis
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX DesignersAshlimarie
 
Robotlegs on Top of Gaia
Robotlegs on Top of GaiaRobotlegs on Top of Gaia
Robotlegs on Top of GaiaJesse Warden
 
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
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesTikal Knowledge
 
Ajax to the Moon
Ajax to the MoonAjax to the Moon
Ajax to the Moondavejohnson
 
Beyond the Basics, Debugging with Firebug and Web Inspector
Beyond the Basics, Debugging with Firebug and Web InspectorBeyond the Basics, Debugging with Firebug and Web Inspector
Beyond the Basics, Debugging with Firebug and Web InspectorSteven Roussey
 
From Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceFrom Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceSebastian Springer
 
Intro to-html-backbone
Intro to-html-backboneIntro to-html-backbone
Intro to-html-backbonezonathen
 
Our application got popular and now it breaks
Our application got popular and now it breaksOur application got popular and now it breaks
Our application got popular and now it breaksColdFusionConference
 
Our application got popular and now it breaks
Our application got popular and now it breaksOur application got popular and now it breaks
Our application got popular and now it breaksdevObjective
 
WPF for developers - optimizing your WPF application
WPF for developers - optimizing your WPF applicationWPF for developers - optimizing your WPF application
WPF for developers - optimizing your WPF applicationTamir Khason
 
(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe(In)Security Implication in the JS Universe
(In)Security Implication in the JS UniverseStefano Di Paola
 
Optimizing Flex Applications
Optimizing Flex ApplicationsOptimizing Flex Applications
Optimizing Flex Applicationsdcoletta
 
Joomla Day Austin Part 4
Joomla Day Austin Part 4Joomla Day Austin Part 4
Joomla Day Austin Part 4Kyle Ledbetter
 

Similar a Performance Best Practices - Part 1 - Client Side [JS, CSS, HTML, jQuery] (20)

AtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
AtlasCamp 2011 - Five Strategies to Accelerate Plugin DevelopmentAtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
AtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
 
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP MeetupWeb Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
 
Introduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopIntroduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint Workshop
 
3 Tips to Deliver Fast Performance Across Mobile Web
3 Tips to Deliver Fast Performance Across Mobile Web3 Tips to Deliver Fast Performance Across Mobile Web
3 Tips to Deliver Fast Performance Across Mobile Web
 
Sinatra and JSONQuery Web Service
Sinatra and JSONQuery Web ServiceSinatra and JSONQuery Web Service
Sinatra and JSONQuery Web Service
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
 
Robotlegs on Top of Gaia
Robotlegs on Top of GaiaRobotlegs on Top of Gaia
Robotlegs on Top of Gaia
 
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
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
 
Ajax to the Moon
Ajax to the MoonAjax to the Moon
Ajax to the Moon
 
Beyond the Basics, Debugging with Firebug and Web Inspector
Beyond the Basics, Debugging with Firebug and Web InspectorBeyond the Basics, Debugging with Firebug and Web Inspector
Beyond the Basics, Debugging with Firebug and Web Inspector
 
From Zero to Hero – Web Performance
From Zero to Hero – Web PerformanceFrom Zero to Hero – Web Performance
From Zero to Hero – Web Performance
 
Intro to-html-backbone
Intro to-html-backboneIntro to-html-backbone
Intro to-html-backbone
 
Our application got popular and now it breaks
Our application got popular and now it breaksOur application got popular and now it breaks
Our application got popular and now it breaks
 
Our application got popular and now it breaks
Our application got popular and now it breaksOur application got popular and now it breaks
Our application got popular and now it breaks
 
WPF for developers - optimizing your WPF application
WPF for developers - optimizing your WPF applicationWPF for developers - optimizing your WPF application
WPF for developers - optimizing your WPF application
 
(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe
 
Optimizing Flex Applications
Optimizing Flex ApplicationsOptimizing Flex Applications
Optimizing Flex Applications
 
Joomla Day Austin Part 4
Joomla Day Austin Part 4Joomla Day Austin Part 4
Joomla Day Austin Part 4
 

Más de Mindfire Solutions (20)

Physician Search and Review
Physician Search and ReviewPhysician Search and Review
Physician Search and Review
 
diet management app
diet management appdiet management app
diet management app
 
Business Technology Solution
Business Technology SolutionBusiness Technology Solution
Business Technology Solution
 
Remote Health Monitoring
Remote Health MonitoringRemote Health Monitoring
Remote Health Monitoring
 
Influencer Marketing Solution
Influencer Marketing SolutionInfluencer Marketing Solution
Influencer Marketing Solution
 
ELMAH
ELMAHELMAH
ELMAH
 
High Availability of Azure Applications
High Availability of Azure ApplicationsHigh Availability of Azure Applications
High Availability of Azure Applications
 
IOT Hands On
IOT Hands OnIOT Hands On
IOT Hands On
 
Glimpse of Loops Vs Set
Glimpse of Loops Vs SetGlimpse of Loops Vs Set
Glimpse of Loops Vs Set
 
Oracle Sql Developer-Getting Started
Oracle Sql Developer-Getting StartedOracle Sql Developer-Getting Started
Oracle Sql Developer-Getting Started
 
Adaptive Layout In iOS 8
Adaptive Layout In iOS 8Adaptive Layout In iOS 8
Adaptive Layout In iOS 8
 
Introduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/MacIntroduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/Mac
 
LINQPad - utility Tool
LINQPad - utility ToolLINQPad - utility Tool
LINQPad - utility Tool
 
Get started with watch kit development
Get started with watch kit developmentGet started with watch kit development
Get started with watch kit development
 
Swift vs Objective-C
Swift vs Objective-CSwift vs Objective-C
Swift vs Objective-C
 
Material Design in Android
Material Design in AndroidMaterial Design in Android
Material Design in Android
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
 
Ext js Part 2- MVC
Ext js Part 2- MVCExt js Part 2- MVC
Ext js Part 2- MVC
 
ExtJs Basic Part-1
ExtJs Basic Part-1ExtJs Basic Part-1
ExtJs Basic Part-1
 
Spring Security Introduction
Spring Security IntroductionSpring Security Introduction
Spring Security Introduction
 

Último

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
[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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
[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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Performance Best Practices - Part 1 - Client Side [JS, CSS, HTML, jQuery]

  • 1. Performance Best Practices - Part 1 - Client Side [JS, CSS, HTML, jQuery] Presenter: Sathyan, Mindfire Solutions Date: 03rd Sep 2013
  • 3. Presenter: Sathyan, Mindfire Solutions  Average Frontend time is 75% and above  No inline JavaScript  No Inline Styles  Refer only the necessary include [js, css, etc.] files for the page  Always remove code, DOM, CSS that you do not need – Sample  Minimal comments, comment only what the code does and not how!  Use JSON  Less less less
  • 4. Presenter: Sathyan, Mindfire Solutions  Minimize HTTP Requests  Put Stylesheets at the Top  Put Scripts at the Bottom  Avoid Redirects  Make Ajax Cacheable  Use GET for AJAX Requests  Post-load Components  Preload Components  Reduce the Number of DOM Elements
  • 6.  JAX  What?  Really?  AJAX Control Toolkit  But I need It…  Callback  Read  See Presenter: Sathyan, Mindfire Solutions
  • 7. Presenter: Sathyan, Mindfire Solutions  CSS Sprites  http://www.websiteoptimization.com/speed/ tweak/css-sprites/  Replace graphic rollovers with CSS rollovers  colored backgrounds, borders, or spacing instead of graphic techniques  Replace graphic text headers with CSS text headers
  • 8. Presenter: Sathyan, Mindfire Solutions  Use efficient CSS selectors ◦ Right to left $(“body #container div a”) ◦ Rules with descendants body * {...}.hide-scrollbars * {...} ◦ Rules with child or adjacent selectors body > * {...}.hide- scrollbars * {...} ◦ Rules with overly qualified selectors – IDs with tags ◦ Remove redundant qualifiers.  Avoid CSS expressions [ IE 5 – 7]  Put CSS in the document head  Specify image dimensions  Specify a character set
  • 9. Presenter: Sathyan, Mindfire Solutions  CSS 3 ?  Group Similar Styles  Reduce No of line breaks  Simple colors #333333, #DDDDDD, #112255, #AABBCC, #FF0000 to #333, #DDD, #125, #ABC, #F00  Remove “px”  Images
  • 10. Presenter: Sathyan, Mindfire Solutions  Scroll, Resize   Chrome Developer Tools – Profiles – flipkart  CSS Stress Test  Chrome Developer Tools – Timeline Ctrl E R flipkart  Chrome Developer Tools –Audit
  • 11. Presenter: Sathyan, Mindfire Solutions  Native JS Code  Grouping  Reuse  Caching  Refer an element as directly as possible using the ID selector rather than using search/find in a container, yes that is right, because it translates directly to good old getElementByID()
  • 12.  Concat with Array.prototype.join() – Really?  Data Structures Push() pop() Shift() - Read  Use ‘this’  Switch it!  Loops $.each() Vs Native  Initializing instance variables  Know your Closures  Cache – $(".someelement") -- Assign to a Var! Presenter: Sathyan, Mindfire Solutions
  • 13. Presenter: Sathyan, Mindfire Solutions  Always Unbind before binding  Most abused part  Leads to repeated calls  Repeated requests leads to pathetic web page  See
  • 14.  DOM Manipulation is BAD for (var ct=0; ct <1000; ++ct) { $("#header").html($("#header").html() + ‘something from resultset’); } should be written as: var fullHeaderContent = $("#header").html(); for (var ct=0; ct <1000; ++ct) { fullHeaderContent += ‘something from resultset’; } $("#header").html(fullHeaderContent ); Presenter: Sathyan, Mindfire Solutions
  • 15. //BAD for (var ctPatient=0; ctPatient<=rows.length; ++ctPatient) { $('#alertResult').append('<tr><td>'+rows[ctPatient]+'</td></tr>'); } // AWESOME var domTree = ''; for (var ctPatient=0; ctPatient<=rows.length; ++ctPatient) { domTree += '<tr><td>'+rows[ctPatient]+'</td></tr>'; } $('#alertResult').append(domTree); Presenter: Sathyan, Mindfire Solutions
  • 16. Presenter: Sathyan, Mindfire Solutions  Avoid using pseudo and attribute selectors ◦ $(‘:visible, :hidden’); $(’[attribute=value]’);  Class Selectors Next Slower [IE9]  Tags!  ID ID ID ID  Chaining – Multi Selectors  Sizzle
  • 17.  Depth of call stack  Rapid fire rounds – 2 to 3 milliseconds  Even bubbling – Super Post  Mouseup Vs Click Presenter: Sathyan, Mindfire Solutions
  • 18. $("#longlist li").on("mouseenter", function() { $(this).text("Click me!"); }); $("#longlist li").on("click", function() { $(this).text("Why did you click me?!"); }); var list = $("#longlist"); list.on("mouseenter", "li", function(){ $(this).text("Click me!"); }); list.on("click", "li", function() { $(this).text("Why did you click me?!"); }); http://gregfranko.com/jquery-best-practices/#/20
  • 19.  Hello World!  Why?  Options?  Window Events? Presenter: Sathyan, Mindfire Solutions
  • 20.  It matters  The latest is the greatest, always Presenter: Sathyan, Mindfire Solutions
  • 21.  The best Javascript debugger out there!  Console shows warning, errors, info  Look for Yellow and Red – If you see them, they are bad, get rid of those warnings, errors right away!  Do you see 404? Bad, Very Bad, Please act on it  Are there repeated calls? No use of “stressing” the point here, get rid of duplicate calls.  Net Tab – Wait time - receive time Presenter: Sathyan, Mindfire Solutions
  • 22.  Asynch Calls for Wait time  Number of requests – can they be reduced? Are there repeated calls? Where is the most time spent?  Categorize the bottlenecks using the waterfall charts  console.profile, console.time and other Console APIs are very powerful, learn and use http://getfirebug.com/wiki/index.php/Conso le_API Presenter: Sathyan, Mindfire Solutions
  • 23.  Yslow ◦ Use a Content Delivery Network (CDN) ◦ Add Expires headers ◦ Avoid empty src or href ◦ Compress components with gzip ◦ Configure entity tags (ETags) ◦ Make favicon small and cacheable ◦ Minification ◦ Bundling ◦ One Big JS/CSS Presenter: Sathyan, Mindfire Solutions
  • 24.  uniform way to analyze and report on the degree to which measured performance meets user expectations.  Set Your Apdex Score  Et Your Apdex Score Presenter: Sathyan, Mindfire Solutions
  • 25.  Chrome Developer Tools – Audit  Miniprofiler  Glimpse  Firebug - Network  Yslow  PageSpeed  Newrelic  http://www.webpagetest.org/  https://code.google.com/p/leak-finder-for- javascript/ Presenter: Sathyan, Mindfire Solutions
  • 27. Presenter: Sathyan, Mindfire Solutions  http://www.stevesouders.com  http://www.websiteoptimization.com/  http://www.webpagetest.org/  http://webdevchecklist.com/asp.net/performance/  http://www.strangeloopnetworks.com/assets/images/visualizing_web_performance_pos ter.jpg  https://developers.google.com/speed/pagespeed/?csw=1  https://developers.google.com/speed/docs/best-practices/rendering  http://oreilly.com/server-administration/excerpts/even-faster-websites/writing- efficient-javascript.html  http://gregfranko.com/jquery-best-practices/#/  http://www.artzstudio.com/2009/04/jquery-performance-rules/  http://vimeo.com/43659068  http://addyosmani.com/blog/  http://www.webperformancetoday.com/2010/07/09/waterfalls-101/
  • 28. Presenter: Sathyan, Mindfire Solutions Question and Answer  HTML5?  Local Storage?  Web Sockets?  http://phantomjs.org/  Node.js  Backbone.js
  • 29. Presenter: Sathyan, Mindfire Solutions Thank you