SlideShare a Scribd company logo
Optimizing AngularJS Application
Md. 
Ziaul 
Haq 
Sr. 
JavaScript 
Developer 
oDesk 
Inc. 
@jquerygeek
¡ What 
&& 
Why
¡ Identify 
the 
problems 
¡ The 
solution 
with 
best 
practices 
¡ Few 
more 
best 
practices
Optimizing AngularJS Application
Optimizing AngularJS Application
¡ Network 
related 
issue 
¡ Unexpected 
characters 
¡ Slow 
DOM 
¡ Slow 
watcher
¡ Minify 
your 
codes 
§ Use 
Uglify
Optimizing AngularJS Application
¡ Write 
minify 
safe 
code 
§ Use 
Dependency 
Annotation
¡ Without 
Dependency 
Annotation 
myApp.service(’myService’, 
function($http){ 
console.log($http); 
});
¡ Without 
Dependency 
Annotation 
myApp.service("myService", 
function(a){ 
console.log(a) 
});
¡ With 
Dependency 
Annotation 
myApp.service(’myService’, 
[‘$http’, function($http){ 
console.log($http); 
}]);
¡ Use 
‘ng-­‐annotate’ 
§ https://github.com/olov/ng-­‐annotate
¡ Lot 
of 
network 
request 
§ Mostly 
for 
template 
files
¡ Cache 
the 
templates 
§ Use 
$templateCache 
service
myApp.run([‘$templateCache’, 
function($templateCache) { 
$templateCache.put('tpls/ 
hello.html', '<div class='hello 
'>Hello, {{world}}!</div>’); 
}]);
¡ For 
grunt 
§ https://github.com/karlgoldstein/grunt-­‐html2js 
¡ For 
gulp 
§ https://github.com/fraserxu/gulp-­‐html2js
Optimizing AngularJS Application
¡ Template 
tag 
{{ 
}} 
in 
landing 
page
— Hide 
the 
body/some 
element, 
till 
bootstrap 
angular 
— Use 
ng-­‐cloak
<Style> 
[ng-cloak] { 
display: none; 
} 
</style> 
<body ng-cloak>
▪ Hide 
individual 
expressions 
▪ Use 
ng-­‐bind 
<span ng-bind=”data.value”> 
</span>
¡ https://builtwith.angularjs.org/
¡ Repeating 
manipulation
¡ Optimize 
ng-­‐repeat 
§ Use 
the 
track 
by 
syntax 
<li ng-repeat=” 
item in data.items 
track by item.id ”> 
</li>
¡ Use 
bind-­‐once 
<li ng-repeat=” 
item in ::data.items"> 
{{::item.title}} 
</li>
¡ Filter 
in 
controller, 
not 
in 
‘ng-­‐repeat’
Optimizing AngularJS Application
¡ Do 
you 
need 
$watch? 
¡ Use 
unWatch 
¡ Keep 
$watch 
smaller 
and 
focused 
¡ Avoid 
loop 
in 
$watch
¡ Avoid 
deep 
comparison 
$scope.user = { 
id: grrey, 
name: Gandaf Grey, 
email: ggreay@gmail.com 
} 
$scope.$watch('user', function(newUser) { 
//... 
}, true);
¡ Keep 
filter 
simple 
with 
single 
task 
¡ Use 
bind-­‐once 
¡ Keep 
less 
item 
in 
ng-­‐repeat
Optimizing AngularJS Application
Optimizing AngularJS Application
¡ Bootstrap 
Angular 
app 
§ Angular-­‐seed 
https://github.com/angular/angular-­‐seed 
§ Angular-­‐fun 
https://github.com/CaryLandholt/ 
AngularFun
¡ Separate 
the 
business 
logic 
§ Controller 
▪ Manipulate 
DOM 
in 
Controller 
Directives 
▪ Commonly 
used 
functions 
as 
service. 
▪ Use 
$emit, 
$broadcast 
or 
$on 
to 
communicate 
with 
other 
controller.
¡ Separate 
the 
business 
logic 
§ Service 
▪ Should 
not 
refer 
DOM 
▪ All 
business 
login 
in 
service
§ Directive 
▪ DOM 
manipulations 
must 
in 
directives 
▪ Use 
scope 
instead 
of 
$scope 
in 
link 
▪ Isolated 
scope 
for 
reusable 
components. 
▪ Custom 
prefix 
to 
avoid 
conflict 
▪ Don’t 
use 
‘ng’ 
and 
‘ui’ 
as 
prefix.
§ Use 
of 
Directive 
▪ Use 
‘data’ 
prefix 
for 
valid 
HTML 
" 
<div data-my-directive> 
</div>
¡ Choose 
the 
better 
one 
§ Use 
promises 
($q) 
instead 
of 
old 
callbacks. 
§ Use 
ngIf 
instead 
of 
ngShow 
& 
ngHide
¡ Choose 
the 
better 
one 
§ Use 
ng-­‐src 
instead 
of 
src=“{{ 
}}” 
§ Use 
ng-­‐href 
instead 
of 
href=“{{ 
}}”
¡ Avoid 
old/jQuery 
habit 
§ $timeout 
instead 
of 
setTimeout 
§ $interval 
instead 
of 
setInterval 
§ $window 
instead 
of 
window 
§ $document 
instead 
of 
document 
§ $http 
instead 
of 
$.ajax
¡ https://docs.angularjs.org/ 
¡ https://github.com/mgechev/angularjs-­‐style-­‐ 
guide 
¡ ng-­‐book
Optimizing AngularJS Application
Thanks, 
all. 
J 
Drop 
me 
a 
line 
if 
more 
question 
jquerygeek@elance-­‐odesk.com

More Related Content

KEY
I18n
PDF
Python for AngularJS
PDF
Telling Stories With RSpec
PDF
Scaling Rails Sites by default
PDF
Fronted From Scratch - Supercharge Magento page speed
PDF
XpDays - Automated testing of responsive design (GalenFramework)
PDF
Integrating React.js Into a PHP Application
PDF
AngularJS Deep Dives (NYC GDG Apr 2013)
I18n
Python for AngularJS
Telling Stories With RSpec
Scaling Rails Sites by default
Fronted From Scratch - Supercharge Magento page speed
XpDays - Automated testing of responsive design (GalenFramework)
Integrating React.js Into a PHP Application
AngularJS Deep Dives (NYC GDG Apr 2013)

What's hot (20)

PDF
Capybara with Rspec
PDF
AngularJS meets Rails
PPTX
React basic by Yoav Amit, Wix
ODP
PPTX
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
PPTX
Capybara + RSpec - ruby dsl-based web ui qa automation
PDF
Lunch and learn: Cucumber and Capybara
PDF
Performance
PDF
Angularjs & REST
PDF
Ruby on Rails - UNISO
PDF
From ActiveRecord to EventSourcing
PDF
Introduction to VueJS & The WordPress REST API
PDF
I18n of java script
PDF
NextJS - Online Summit for Frontend Developers September 2020
PDF
ReactJS Workflows
PPTX
Angular 1.5 Components
PDF
Plugging into plugins
PDF
Drupal8 + AngularJS
PDF
REST in AngularJS
PDF
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Capybara with Rspec
AngularJS meets Rails
React basic by Yoav Amit, Wix
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
Capybara + RSpec - ruby dsl-based web ui qa automation
Lunch and learn: Cucumber and Capybara
Performance
Angularjs & REST
Ruby on Rails - UNISO
From ActiveRecord to EventSourcing
Introduction to VueJS & The WordPress REST API
I18n of java script
NextJS - Online Summit for Frontend Developers September 2020
ReactJS Workflows
Angular 1.5 Components
Plugging into plugins
Drupal8 + AngularJS
REST in AngularJS
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Ad

Viewers also liked (7)

PDF
Reactive data visualisations with Om
PDF
Habits of Effective Designers - Handout
PDF
Art of-presentations
PDF
Habits of Effective Designers
PDF
Mapping with Adobe CC
PDF
Intro to Adobe Illustrator
PDF
Javascript Best Practices
Reactive data visualisations with Om
Habits of Effective Designers - Handout
Art of-presentations
Habits of Effective Designers
Mapping with Adobe CC
Intro to Adobe Illustrator
Javascript Best Practices
Ad

Similar to Optimizing AngularJS Application (20)

PPTX
Optimizing a large angular application (ng conf)
PDF
[Ebooks PDF] download AngularJS 1st Edition Brad Green full chapters
PDF
Advanced Tips & Tricks for using Angular JS
PDF
Tips from angular js users anonymous
PPT
Angular js meetup
PPT
angularjsmeetup-150303044616-conversion-gate01
PPTX
Optimizing Angular Performance in Enterprise Single Page Apps
PPTX
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
PDF
AngularJS in practice
PDF
AngularJS Workshop
PPTX
AngularJS best practices
PPTX
AngularJS One Day Workshop
PPTX
AngularJS Best Practices
PPTX
AngularJS.part1
PPTX
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
PPTX
Bhuvi ppt zerobug
PPTX
Intro to AngularJs
PDF
Beginning AngularJS
PPTX
Angular js for Beginnners
PDF
Angular js gtg-27feb2013
Optimizing a large angular application (ng conf)
[Ebooks PDF] download AngularJS 1st Edition Brad Green full chapters
Advanced Tips & Tricks for using Angular JS
Tips from angular js users anonymous
Angular js meetup
angularjsmeetup-150303044616-conversion-gate01
Optimizing Angular Performance in Enterprise Single Page Apps
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
AngularJS in practice
AngularJS Workshop
AngularJS best practices
AngularJS One Day Workshop
AngularJS Best Practices
AngularJS.part1
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Bhuvi ppt zerobug
Intro to AngularJs
Beginning AngularJS
Angular js for Beginnners
Angular js gtg-27feb2013

More from Md. Ziaul Haq (6)

PDF
Pwa with vue js
PDF
Taste of RxJS
PDF
The MEAN Stack
PDF
Overview on jQuery mobile
PDF
Jquery plugin development
PPT
Kick start with j query
Pwa with vue js
Taste of RxJS
The MEAN Stack
Overview on jQuery mobile
Jquery plugin development
Kick start with j query

Recently uploaded (20)

PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Approach and Philosophy of On baking technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
cuic standard and advanced reporting.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Mobile App Security Testing_ A Comprehensive Guide.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Approach and Philosophy of On baking technology
Digital-Transformation-Roadmap-for-Companies.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
cuic standard and advanced reporting.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
“AI and Expert System Decision Support & Business Intelligence Systems”
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation theory and applications.pdf
Spectral efficient network and resource selection model in 5G networks
Network Security Unit 5.pdf for BCA BBA.
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Encapsulation_ Review paper, used for researhc scholars
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

Optimizing AngularJS Application