background preloader

HTML5

Facebook Twitter

HTML5 Cross Browser Polyfills - GitHub. The No-Nonsense Guide to HTML5 Fallbacks So here we're collecting all the shims, fallbacks, and polyfills in order to implant HTML5 functionality in browsers that don't natively support them. The general idea is that: We, as developers, should be able to develop with the HTML5 APIs, and scripts can create the methods and objects that should exist. Developing in this future-proof way means as users upgrade, your code doesn't have to change but users will move to the better, native experience cleanly. Looking to conditionally load these scripts (client-side), based on feature detects? See Modernizr.Looking for a guide to write your own polyfills? See Writing Cross-Browser JavaScript Polyfills.Looking for an alphabetical guide on HTML5, CSS3, etc. features, and how to use them? Svgweb by Brad Neuberg & others Fallback via FlashSnap.SVG from scratch by the author of Raphaël (Dmitry Baranovskiy) Abstracted API.

FakeSmile by David Leunen Canvas Web Storage (LocalStorage and SessionStorage) Video. Web Applications 1.0.

Game dev

Web Workers rise up! By Daniel Davis Introduction Picture this. You are the dear leader of the little-known land of ScravaJipt, reigning supreme over all you survey. You have a chief servant to look after you, buy your clothes, press the buttons on your mobile phone. The raison d'être of Web Workers Have you ever been to a page that displayed partially but didn't respond to any clicks?

The cause was most likely JavaScript. Web developers are not going to (and shouldn't have to) cut back on their use of JavaScript because of this. How Web Workers work Most modern programming languages are multi-threaded, meaning they can run several processes simultaneously. When can I use them? Going back to our 'specialists' analogy, Web Workers can only do one thing but they do it very well. Using Web Workers is the same.

Just show me the code! Stay calm, we're getting there! In our main JavaScript thread we use our worker by creating a new Worker object: var worker = new Worker('worker.js'); Things to bear in mind if (!! Periodic Table of the Elements - Josh Duck. Sectioning-flowchart.png (841×595) HTML5 enabling script. 7 Jan Since HTML5 is getting more attention by way of marking up our new pages, and the only way to get IE to acknowledge the new elements, such as <article>, is to use the HTML5 shiv, I’ve quickly put together a mini script that enables all the new elements. Download html5shiv.js and must be inserted in the head element (this is because IE needs to know about the element before it comes to render them – so it can’t sit in the footer of the page, i.e. below the elements in question).

I’ve updated this post to link to Alexander Farkas’s version of the shiv – it’s the very latest and my simple one line script. The one I originally released was (I thought) beautifully small, but didn’t support print styles nor dynamic injection of HTML5 elements. Good thing there are smarter folk than I! InnerShiv makes HTML5shim work on innerHTML & jQuery. When can I use... Support tables for HTML5, CSS3, etc. MicroSoft HTML5Labs. Blogs. Popcorn.js - The HTML5 Video Framework.

Tips

Unit testing. Object URLs. Using the File API, which was added to the DOM in HTML5, it's now possible for web content to ask the user to select local files, then read the contents of those files. This selection can be done by either using an HTML <input> element, or by drag and drop. If you want to use the DOM File API from extensions or other browser chrome code, you can; in fact, there are some additional features to be aware of. See Using the DOM File API in chrome code for details. Accessing selected file(s) Consider this HTML: The File API makes it possible to access a FileList containing File objects representing the files selected by the user. If the user selects just one file, it is then only necessary to consider the first file of the list. Accessing one selected file using a classical DOM selector: var selected_file = document.getElementById('input').files[0]; Accessing one selected file using a jQuery selector: var selected_file = $('#input').get(0).files[0]; Accessing selected file(s) on a change event name size.

Using object URLs to display images. Using the File API, which was added to the DOM in HTML5, it's now possible for web content to ask the user to select local files, then read the contents of those files. This selection can be done by either using an HTML <input> element, or by drag and drop. If you want to use the DOM File API from extensions or other browser chrome code, you can; in fact, there are some additional features to be aware of. See Using the DOM File API in chrome code for details. Accessing selected file(s) Consider this HTML: The File API makes it possible to access a FileList containing File objects representing the files selected by the user. If the user selects just one file, it is then only necessary to consider the first file of the list. Accessing one selected file using a classical DOM selector: var selected_file = document.getElementById('input').files[0]; Accessing one selected file using a jQuery selector: var selected_file = $('#input').get(0).files[0]; Accessing selected file(s) on a change event name size.

Example. Window.URL.createObjectURL. « DOM Reference « URL This is an experimental technologyBecause this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes. Summary The URL.createObjectURL() static method creates a DOMString containing an URL representing the object given in parameter. The URL lifetime is tied to the document in the window on which it was created. The new object URL represents the specified File object or Blob object. Syntax objectURL = URL.createObjectURL(blob); Parameters blob Is a File object or a Blob object to create a object URL for.

Example See Using object URLs to display images. Notes Each time you call createObjectURL(), a new object URL is created, even if you've already created one for the same object. Specifications Browser compatibility See also Document Tags and Contributors. FormData - MDC Doc Center. XMLHttpRequest Level 2 adds support for the new FormData interface. FormData objects provide a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data". For details on how to use the FormData object, see Using FormData objects.

Constructor new FormData (optional HTMLFormElement form) Parameters form Optional HTML Form Element <form> to send for keys/values. Methods append() Appends a key/value pair to the FormData object. Parameters name The name of the field whose data is contained in value. value The field's value. Filename Optional The filename reported to the server, when a Blob or File is passed as second paramter. Browser compatibility Note: XHR in Android 4.0 sends empty content for FormData with blob. Gecko notes Specification See also Document Tags and Contributors. Typed Array Specification. Editor's Draft 18 July 2013 This version: Web IDL: Latest version: Previous version: Web IDL: Editors: David Herman (Mozilla Corporation) Kenneth Russell (Google, Inc.) Abstract This specification provides an API for interoperability with native binary data. The functionality described here originated in the WebGL specification [WEBGL].

Status of this document This document is an editor's draft. The latest version of this document, including all revision history, may be obtained via Subversion: svn co Table of contents 1 Introduction ECMAScript [ECMA-262] has traditionally been used in contexts where there is no access to binary data. 2 Overview 2.1 Endianness 5 The ArrayBuffer Type. JavaScript typed arrays. Draft This page is not complete. As web applications become more and more powerful, adding features such as audio and video manipulation, access to raw data using WebSockets, and so forth, it has become clear that there are times when it would be helpful for JavaScript code to be able to quickly and easily manipulate raw binary data.

In the past, this had to be simulated by treating the raw data as a string and using the charCodeAt() method to read the bytes from the data buffer. However, this is slow and error-prone, due to the need for multiple conversions (especially if the binary data is not actually byte-format data, but, for example, 32-bit integers or floats). JavaScript typed arrays provide a mechanism for accessing raw binary data much more efficiently. Buffers and views: typed array architecture To achieve maximum flexibility and efficiency, JavaScript typed arrays split the implementation into a buffer and a view. Typed array subclasses Typed arrays superclasses Compatibility. Regular vs. Typed - Benchmark. You probably know by now that JavaScript is getting a lot of upgrades at the moment. One of the upgrades that WebGL is bringing along for the ride is JavaScript Typed Arrays.

A JavaScript Typed Array is very quick! It exists as a fixed block of memory that can be accessed with JavaScript, where as a regular JS Array is inherently very slow, being a hash lookup. There are a few different kinds of JS Typed Array like Float32Array, Int8Array, and they are designed to work quickly with binary data for use with WebGL. Read more about JavaScript Typed Arrays here: JS Typed Arrays on MDC Note: A JavaScript Typed Array will only let you store “one type” of variable within it, you can not mix strings and floats. Regular vs. Here are the results of a simple test between a regular JavaScript array, and a Float32Array in Firefox4 Beta1 in milliseconds per operation on an array with a length of 100-million indices.

The Scripts These are the two scripts I ran to get the results above. Int16Array. The Int16Array type represents an array of twos-complement 16-bit signed integers in the platform byte order. If control over byte order is needed, use DataView instead. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).

Constructors Method overview Attributes Constants Element size Constructor Returns a new Int16Array object. Int16Array Int16Array( unsigned long length ); Int16Array Int16Array( TypedArray array ); Int16Array Int16Array( sequence<type> array ); Int16Array Int16Array( ArrayBuffer buffer, optional unsigned long byteOffset, optional unsigned long length ); Parameters length The number of elements in the byte array. Array An object of any of the typed array types (such as Int32Array), or a sequence of objects of a particular type, to copy into a new ArrayBuffer.

Buffer An existing ArrayBuffer to use as the storage for the new Int16Array object. byteOffset Return value Notes Methods.