Sayed Ahmed Computer Science and Engineering, BUET, Bangladesh MSc, Computer Science, Canada

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

HTML Basics Customizing your site using the basics of HTML.
Samsung Smart TV is a web-based application running on an application engine installed on digital TVs connected to the Internet.
Introducing JavaScript
CHAPTER 15 WEBPAGE OPTIMIZATION. LEARNING OBJECTIVES How to test your web-page performance How browser and server interactions impact performance What.
Java Script Session1 INTRODUCTION.
Validation in Angular 1.3 And other angular tidbits.
The Web Warrior Guide to Web Design Technologies
Web Page Behavior IS 373—Web Standards Todd Will.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
1 Chapter 20 — Creating Web Projects Microsoft Visual Basic.NET, Introduction to Programming.
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
HTML5. What is HTML5? HTML5 will be the new standard for HTML. HTML5 is the next generation of HTML. HTML5 is still a work in progress. However, the major.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
4.1 JavaScript Introduction
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
SUNY Polytechnic Institute CS 490 – Web Design, AJAX, jQueryAngularJS AngularJS is a client-side JavaScript Framework for adding interactivity to HTML.
JavaScript & jQuery the missing manual Chapter 11
Philly.NET Hands-on Labs JAVASCRIPT SERIES. July 9: JavaScript Syntax Visual Studio ◦Projects ◦Editors ◦Debugging ◦Script blocks ◦Minification and bundling.
Server-side Scripting Powering the webs favourite services.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
JQUERY | INTRODUCTION. jQuery  Open source JavaScript library  Simplifies the interactions between  HTML document, or the Document Object Model (DOM),
Krishna Mohan Koyya Glarimy Technology Services
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
1 JavaScript
Introduction to JavaScript CS101 Introduction to Computing.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
1 3 Computing System Fundamentals 3.4 Networked Computer Systems.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
Canopy walk through Single-Page Apps (SPAs) Benjamin Howarth Freelancer, Code Gecko Umbraco UK Festival, Fri 30 th Oct 2015 CODE GECKO.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
JavaScript Introduction. Slide 2 Lecture Overview JavaScript background The purpose of JavaScript A first JavaScript example Introduction to getElementById.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
HTML A brief introduction HTML1. HTML, what is? HTML is a markup language for describing web documents (web pages). HTML stands for Hyper Text Markup.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Bundles, Minification Andres Käver, IT Kolledž
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
JQUERY AND AJAX
World Wide Web has been created to share the text document across the world. In static web pages the requesting user has no ability to interact with the.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Teaching slides Chapter 6. Chapter 6 Software user interface design & construction Contents Introduction Graphical user interface – Rich window based.
Access Problems and Solutions for Full-text Articles or E-books
>> Introduction to JavaScript
Tutorial 10 Programming with JavaScript
Human Computer Interaction
Google Web Toolkit Tutorial
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript an introduction.
Access Problems and Solutions for Full-text Articles or E-books
WEB PROGRAMMING JavaScript.
Secure Web Programming
Teaching slides Chapter 6.
ASP.NET Imran Rashid CTO at ManiWeber Technologies.
Web Client Side Technologies Raneem Qaddoura
Web Programming and Design
Presentation transcript:

Sayed Ahmed Computer Science and Engineering, BUET, Bangladesh MSc, Computer Science, Canada

 Checked on Angular and created the following training video   Partially Read the Book: Mastering Web Application development in AngularJS  Watched the video  Google I/O Design Decisions in AngularJS 

 Watched this but pretty lightly  Introduction to Angular JS   Pretty lightly watched  Karl Seamon - Angular Performance - NG-Conf   Tried to watch but did not finish [still in my tablet]  Security with Angular JS   Testing Strategies for Angular JS 

 MVVM: Such as Angular.JS and Knockout.js   KnockOut.js   Presentation Model by Martin Fowler  ml (theory behind: MVVM) ml (theory behind: MVVM)

 Why Angular? and Why not Angular  10 reasons why use angular?   Why Does Angular.js Rock?   Check the total article and esp the section: Why not Angular, Why not Backbone, Why not Ember   These articles do worth reading:   Bite-sized web development training with AngularJS 

 Mastering Web Application Development with AngularJS  development/book development/book  CRUD Application Demo with Angular   Angular.JS Wiki  

 Recent AngularJS also makes use of regular expressions for form validations such as: 

 AngularJS will work with the latest versions of Chrome, Firefox, Safari, and Opera, as well as Internet Explorer version 8, 9, and 10. You will need to do some extra work for IE8  To make AngularJS Work with IE8 use the following   Though ng-app="application_name" is sufficient for the other browsers as mentioned in point 1; for IE 8, id attribute is also required  We cannot make IE to recognize and include templates in the following manner   Though, we can take a different strategy to make IE8 recognize and include templates by using 

 we have to make IE8 recognize to be able to use this custom tag to include templates. We can do that by using  document.createElement('ng-include'); document.createElement('ng-view');...  Supporting IE7 for AngularJS You need to do everything that you did for IE8. AngularJS was not tested with IE7; so you need to adjust stuff as they come along IE7 does not have many APIs commonly present in web-browsers such as JSON API You will need libraries such as to be included in your application to support JSON  5. IE6 is not supported

 The Issue and Why Optimize  In general, the landing web-page should load fast to have a good impression of the application/web-site. However, that usually requires some extra work and tuning.  If you have developed a single page web-application with AngularJS or you have developed a single page web-based mobile application with AngularJS, you need to optimize the landing page.  It can be tricky to load and display the first page right; with mobile this becomes more tricky. And with Angular, you have to download additional Angular libraries that will inject information or data to make the page look right. If not done right, you may end up showing the templates, and lots of curly braces ( {{ user.name}} ) to your users.  For rescue, there are three helps  ng-bind : Angular Directive  ng-cloak : Angular Directive  AMD : Asynchronous JavaScript Module Loading with Require.js

 Recommendations:  If your first page has lots of dynamic contents, use ng-cloak directive for the dynamic data/information blocks that will hide those sections before AngularJS can kick in and inject data/information. You can even place it in the body tag.  If your first page has mostly static content, use ng-bind for the static content (i.e where you were using curly braces {{}} ). You can also assign some default values for those static places so that before Angular kicks in the default value will be shown. If you do not provide default values those places will be empty before Angular fills information.  If your page has a mix of dynamic and static contents, you can use ng-cloak, and ng-bind together.  You can use asynchronous loading of JavaScript modules. You can use smaller JS files and link them to the pages where they are required. Now, based on the dependencies the scripts will load asynchronously. However, if a page needs too many of the script files, there will be more network overhead. You need to be smart about dividing and linking those script files. Though, performance gain by this strategy probably is debatable. You probably need to measure the performance gain, and again in real world, is the client ready to pay?

 Another Tip  If the page is mostly static, put at the bottom and use ng-bind If the page is mostly dynamic, put at the top and use ng-cloak  Examples of using ng-cloak  Hello, {{name}}!  Example of using ng-bind  Hello, !  If you use Require.js to load angular, you cannot use ng-app directive. You need to use angular.bootstrap method from JavaScript instead  Reference:  Book: Mastering Web Application Development with AngularJS

 Optimizing AngularJS Page Loading:  Optimizing web-applications for faster performance often include reducing network activities, reducing send and receive requests over the network/internet, and reducing data downloads. Minification of JavaScript, CSS, and HTML files can help with that. AngularJS kind of forces to write minification safe JavaScript, and writing array style and annotation based function declaration is recommended.  Creating partial templates and loading related templates in combination may help. Probably, need some experiment and planning before than doing it on the fly. Two ways to preload templates 1. tag 2. $templateCache

 You may want to read one of our other articles on optimizing landing pages for AngularJS single page applications by usinng ng-cloak, and ng-bind  Using Asynchronous script loader such as Require.Js does not improve the performance a lot [according to the book as listed in the reference section]. Hence, so far, AMD is not recomended with AngularJS  You can check how to use Require.JS in your applications at :  You may want to use them in non-AngularJS projects. The idea is, you have to have a consistent project directory structure esp for JavaScript files as recommended and specified by Require.Js. In your, HTML file you refer to the main.js file, single entry point for loading JS code. In that main.js, you will use Require.JS esp. require() to load other JS files asynchronously and as required by your application.

 To use Require.JS with JQuery, you can check the following resource. The adoption may need different considerations for a new project or for adapting existing code for Require.JS

 Securing Your AngularJS Applications Some security measures can be as follows:  Take security measures at the entry and exit  points of data to and from the server  Secure the server and prevent unauthorized access to data, and HTML  Encrypt the connection i.e  Prevent cross-site scripting (XSS),  Prevent cross-site request forgery (XSRF) attacks  Block JSON injections

 AngularJS Templates Securing: $templateCache caches templates if you want to use this. We need to remove the cache for each user login  The following or similar stuff can help Cache-Control: no-cache, no-store, must- revalidate Pragma : no-cache Expires : 0

 using https can address the snooping and man in the middle attack  You need to prevent JSON Injection Vulnerability to do this, you can add )]}', before your JSON, though not valid JSON but helps to prevent JSON injection vulnerability.  Prevent XSS attack in the client side AngularJS escapes all HTML in text that is displayed through the ng-bind directive, or template interpolation (that is text in {{curly braces}}).

 Performance Improvement of AngularJS Applications: Writing Robust AngulaJS Applications  Ideally, you need to measure the performance and apply the strategy based on the outcome. Your intuition may be wrong unless you verify it against real life situations and measure it. Also, testing the performance on real or sample data may help depending on the Application.

 That's right, I did not experience it, but the right knowledge is, you need to be careful about using the $digest loop. Too many iterations such as 50 loops or 100 loops may make your applications unresponsive. The numbber of watches inside the $digest loops, and how fast those watches run also affect performance a lot. You can either reduce the numbber of watches or make the watches faster. You can also monitor memory usage by those watches. Less memory use can make your application faster.

 ng-repeat directive is also performance sensitive. If you use ng-repeat to work on collections having 100s of items, it may cause performance penalty. So either plan and limit the entries in your collections or write custom directives for the purpose. In either case, do it in such a way so that it causes less performance penalty. You need to measure though.

 Localization Support in Angular : Writing International Applications in AngularJS Under the AngularJS library there is a folder i18n where en-us locale related data are kept. If you want to use a different locale you can do it as follows. Notice the script tag with lib/angular/angular-locale_fr-ca.js to support for fr_ca locale. The.js file should have something as below:  angular.module('locale', ['ngLocale']) : module definition with a dependency on the ngLocale module: ...

 Related examples: {{now | date:'fullDate'}} will return full date based on the locale as set {{100 | currency:'€'}} {{ | number}}  Handling Translations: The text to be translated for different language. The primary idea is, you have to have JSON structure with key value pairs for different locales. You need to use the keys in places where you want the translations based on the user locale.  Example: { 'crud.user.remove.success': 'A user was removed successfully.', 'crud.user.remove.error': 'There was a problem removing a user.'... }  In your HTML, you can write something like below  Hello, {{name}}!  to  {{'greetings.hello' | i18n}}, {{name}}!  You do understand that you need the JSON for the locale with the key greetings.hello  ----

 Building Your Own Directives  Directives can appear as HTML elements, attributes, comments, or CSS classes.  Examples  Defining a Directive  angular.module('app', []).directive('myDir', function() { return myDirectiveDefinition; });

 Writing a Button Directive  describe('button directive', function () { var $compile, $rootScope; beforeEach(module('directives.button')); beforeEach(inject(function(_$compile_, _$rootScope_) { $compile = _$compile_; $rootScope = _$rootScope_; }));  it('adds a "btn" class to the button element', function() { var element = $compile(' ')  ($rootScope); expect(element.hasClass('btn')).toBe(true); });  }); });

 Using the button directive  Click Me!  Implementing a Custom Validation Directives  Now we have our tests in place, so we can implement the functionality of the directive:  myModule.directive('validateEquals', function() { return { require: 'ngModel', link: function(scope, elm, attrs, ngModelCtrl) { function validateEqual(myValue) { var valid= (myValue === scope.$eval(attrs.validateEquals)); ngModelCtrl.$setValidity('equal', valid); return valid ? myValue : undefined; }

 ngModelCtrl.$parsers.push(validateEqual); ngModelCtrl.$formatters.push(validateEqual);  scope.$watch(attrs.validateEquals, function() { ngModelCtrl.$setViewValue(ngModelCtrl.$vi ewValue); }); } }; });

 Plunker   Batarang

    Bindonce