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
Ad

Recommended

I18n
I18n
soon
 
Python for AngularJS
Python for AngularJS
Jeff Schenck
 
Telling Stories With RSpec
Telling Stories With RSpec
rahoulb
 
Scaling Rails Sites by default
Scaling Rails Sites by default
Yi-Ting Cheng
 
Fronted From Scratch - Supercharge Magento page speed
Fronted From Scratch - Supercharge Magento page speed
Yousef Cisco
 
XpDays - Automated testing of responsive design (GalenFramework)
XpDays - Automated testing of responsive design (GalenFramework)
Alex Fruzenshtein
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
Andrew Rota
 
AngularJS Deep Dives (NYC GDG Apr 2013)
AngularJS Deep Dives (NYC GDG Apr 2013)
Nitya Narasimhan
 
Capybara with Rspec
Capybara with Rspec
Omnia Helmi
 
AngularJS meets Rails
AngularJS meets Rails
Elena Torró
 
React basic by Yoav Amit, Wix
React basic by Yoav Amit, Wix
Chen Lerner
 
GAEO
GAEO
guest1d183d
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
Brian Hogg
 
Capybara + RSpec - ruby dsl-based web ui qa automation
Capybara + RSpec - ruby dsl-based web ui qa automation
COMAQA.BY
 
Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and Capybara
Marc Seeger
 
Performance
Performance
Derek Kraan
 
Angularjs & REST
Angularjs & REST
Corley S.r.l.
 
Ruby on Rails - UNISO
Ruby on Rails - UNISO
Lucas Renan
 
From ActiveRecord to EventSourcing
From ActiveRecord to EventSourcing
Emanuele DelBono
 
Introduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST API
Caldera Labs
 
I18n of java script
I18n of java script
Junichi Shinohara
 
NextJS - Online Summit for Frontend Developers September 2020
NextJS - Online Summit for Frontend Developers September 2020
Milad Heydari
 
ReactJS Workflows
ReactJS Workflows
Cem Arguvanlı
 
Angular 1.5 Components
Angular 1.5 Components
José Barbosa
 
Plugging into plugins
Plugging into plugins
Josh Harrison
 
Drupal8 + AngularJS
Drupal8 + AngularJS
Daniel Kanchev
 
REST in AngularJS
REST in AngularJS
a_sharif
 
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Gáspár Nagy
 
Reactive data visualisations with Om
Reactive data visualisations with Om
Anna Pawlicka
 
Habits of Effective Designers - Handout
Habits of Effective Designers - Handout
DUSPviz
 

More Related Content

What's hot (20)

Capybara with Rspec
Capybara with Rspec
Omnia Helmi
 
AngularJS meets Rails
AngularJS meets Rails
Elena Torró
 
React basic by Yoav Amit, Wix
React basic by Yoav Amit, Wix
Chen Lerner
 
GAEO
GAEO
guest1d183d
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
Brian Hogg
 
Capybara + RSpec - ruby dsl-based web ui qa automation
Capybara + RSpec - ruby dsl-based web ui qa automation
COMAQA.BY
 
Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and Capybara
Marc Seeger
 
Performance
Performance
Derek Kraan
 
Angularjs & REST
Angularjs & REST
Corley S.r.l.
 
Ruby on Rails - UNISO
Ruby on Rails - UNISO
Lucas Renan
 
From ActiveRecord to EventSourcing
From ActiveRecord to EventSourcing
Emanuele DelBono
 
Introduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST API
Caldera Labs
 
I18n of java script
I18n of java script
Junichi Shinohara
 
NextJS - Online Summit for Frontend Developers September 2020
NextJS - Online Summit for Frontend Developers September 2020
Milad Heydari
 
ReactJS Workflows
ReactJS Workflows
Cem Arguvanlı
 
Angular 1.5 Components
Angular 1.5 Components
José Barbosa
 
Plugging into plugins
Plugging into plugins
Josh Harrison
 
Drupal8 + AngularJS
Drupal8 + AngularJS
Daniel Kanchev
 
REST in AngularJS
REST in AngularJS
a_sharif
 
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Gáspár Nagy
 
Capybara with Rspec
Capybara with Rspec
Omnia Helmi
 
AngularJS meets Rails
AngularJS meets Rails
Elena Torró
 
React basic by Yoav Amit, Wix
React basic by Yoav Amit, Wix
Chen Lerner
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
Brian Hogg
 
Capybara + RSpec - ruby dsl-based web ui qa automation
Capybara + RSpec - ruby dsl-based web ui qa automation
COMAQA.BY
 
Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and Capybara
Marc Seeger
 
Ruby on Rails - UNISO
Ruby on Rails - UNISO
Lucas Renan
 
From ActiveRecord to EventSourcing
From ActiveRecord to EventSourcing
Emanuele DelBono
 
Introduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST API
Caldera Labs
 
NextJS - Online Summit for Frontend Developers September 2020
NextJS - Online Summit for Frontend Developers September 2020
Milad Heydari
 
Angular 1.5 Components
Angular 1.5 Components
José Barbosa
 
Plugging into plugins
Plugging into plugins
Josh Harrison
 
REST in AngularJS
REST in AngularJS
a_sharif
 
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Behavior Driven UI Automation (Agile Testing Days 2017, Potsdam)
Gáspár Nagy
 

Viewers also liked (7)

Reactive data visualisations with Om
Reactive data visualisations with Om
Anna Pawlicka
 
Habits of Effective Designers - Handout
Habits of Effective Designers - Handout
DUSPviz
 
Art of-presentations
Art of-presentations
DUSPviz
 
Habits of Effective Designers
Habits of Effective Designers
DUSPviz
 
Mapping with Adobe CC
Mapping with Adobe CC
DUSPviz
 
Intro to Adobe Illustrator
Intro to Adobe Illustrator
DUSPviz
 
Javascript Best Practices
Javascript Best Practices
Christian Heilmann
 
Reactive data visualisations with Om
Reactive data visualisations with Om
Anna Pawlicka
 
Habits of Effective Designers - Handout
Habits of Effective Designers - Handout
DUSPviz
 
Art of-presentations
Art of-presentations
DUSPviz
 
Habits of Effective Designers
Habits of Effective Designers
DUSPviz
 
Mapping with Adobe CC
Mapping with Adobe CC
DUSPviz
 
Intro to Adobe Illustrator
Intro to Adobe Illustrator
DUSPviz
 
Ad

Similar to Optimizing AngularJS Application (20)

Optimizing a large angular application (ng conf)
Optimizing a large angular application (ng conf)
A K M Zahiduzzaman
 
[Ebooks PDF] download AngularJS 1st Edition Brad Green full chapters
[Ebooks PDF] download AngularJS 1st Edition Brad Green full chapters
kiciunonge
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
Simon Guest
 
Tips from angular js users anonymous
Tips from angular js users anonymous
Oleg Podsechin
 
Angular js meetup
Angular js meetup
Pierre-Yves Gicquel
 
angularjsmeetup-150303044616-conversion-gate01
angularjsmeetup-150303044616-conversion-gate01
Teo E
 
Optimizing Angular Performance in Enterprise Single Page Apps
Optimizing Angular Performance in Enterprise Single Page Apps
Morgan Stone
 
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
Srijan Technologies
 
AngularJS in practice
AngularJS in practice
Eugene Fidelin
 
AngularJS Workshop
AngularJS Workshop
Gianluca Cacace
 
AngularJS best practices
AngularJS best practices
Filip Bruun Bech-Larsen
 
AngularJS One Day Workshop
AngularJS One Day Workshop
Shyam Seshadri
 
AngularJS Best Practices
AngularJS Best Practices
Narek Mamikonyan
 
AngularJS.part1
AngularJS.part1
Andrey Kolodnitsky
 
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
murtazahaveliwala
 
Bhuvi ppt zerobug
Bhuvi ppt zerobug
BhuviS3
 
Intro to AngularJs
Intro to AngularJs
SolTech, Inc.
 
Beginning AngularJS
Beginning AngularJS
Troy Miles
 
Angular js for Beginnners
Angular js for Beginnners
Santosh Kumar Kar
 
Angular js gtg-27feb2013
Angular js gtg-27feb2013
Nitya Narasimhan
 
Optimizing a large angular application (ng conf)
Optimizing a large angular application (ng conf)
A K M Zahiduzzaman
 
[Ebooks PDF] download AngularJS 1st Edition Brad Green full chapters
[Ebooks PDF] download AngularJS 1st Edition Brad Green full chapters
kiciunonge
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
Simon Guest
 
Tips from angular js users anonymous
Tips from angular js users anonymous
Oleg Podsechin
 
angularjsmeetup-150303044616-conversion-gate01
angularjsmeetup-150303044616-conversion-gate01
Teo E
 
Optimizing Angular Performance in Enterprise Single Page Apps
Optimizing Angular Performance in Enterprise Single Page Apps
Morgan Stone
 
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
Srijan Technologies
 
AngularJS One Day Workshop
AngularJS One Day Workshop
Shyam Seshadri
 
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
murtazahaveliwala
 
Bhuvi ppt zerobug
Bhuvi ppt zerobug
BhuviS3
 
Beginning AngularJS
Beginning AngularJS
Troy Miles
 
Ad

More from Md. Ziaul Haq (6)

Pwa with vue js
Pwa with vue js
Md. Ziaul Haq
 
Taste of RxJS
Taste of RxJS
Md. Ziaul Haq
 
The MEAN Stack
The MEAN Stack
Md. Ziaul Haq
 
Overview on jQuery mobile
Overview on jQuery mobile
Md. Ziaul Haq
 
Jquery plugin development
Jquery plugin development
Md. Ziaul Haq
 
Kick start with j query
Kick start with j query
Md. Ziaul Haq
 

Recently uploaded (20)

From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 

Optimizing AngularJS Application