PHP and WebSockets

Somebody had to do it
So here is a quick hack to implement websockets in php.
As of Dec/09 the only browser that supports websockets is Google Chrome.
Get the developers release from here Google Chrome Dev Channel
Hurry up Firefox and Safari, you're late to the party!

Read more »

JEDI - Javascript Embedded Data Islands

If you want to embed data islands in your HTML, here is an easy way to do it.

First lets create a script tag with a data attribute and put the javascript values inside it like this:

<script data>
mydata="myvalue";
</script>  

We can use any javascript data we want, like objects, arrays, nested elements, etc. so lets try a more complex example:

Read more »

Local Storage

There is a new way to store information on the client side besides cookies.
Welcome to local storage.

Local storage was designed to let you save bits of information in the form of key:value pairs, but here we will try to store collections to make local storage more useful for offline storage, more like a local database.

Read more »

Query Selector

The simplest way to access dom elements by any possible selector:

function $(selector,context){ 
  var result;
  context=context||document;
  if(selector[0]=="#") result=context.querySelector(selector); 
  else result=context.querySelectorAll(selector);
  return result;
}

Examples:

mydiv  = $("#mydiv");
mylist = $("li");
links  = $("a");
for(i in links) write(links[i].href);

Implemented in all modern browsers.