Thursday, November 27, 2014

What’s New in Chrome 39

Despite being six years old, Chrome is rapidly approaching middle age in version numbers. Chrome 39 has been released and you probably have it installed. There are a few nice new features … plus one or two more suspect additions.


ECMAScript 6 Generators


Generators are special functions declared with function* which create iterators. An iterator is an object with a next() method which is called to return a value. The generator function uses a yield statement to provide the next value in the sequence. Arunoda Susiripala provides a basic example in JavaScript Generators and Preventing Callback Hell:

function* HelloGen() {
yield 100;
yield 400;
}

var gen = HelloGen();

console.log(gen.next()); // {value: 100, done: false}
console.log(gen.next()); // {value: 400, done: false}
console.log(gen.next()); // {value: undefined, done: true}


ECMAScript 6 Generators are supported in Chrome, Opera and Firefox 31+.

The Beacon API


The new Beacon API lets you send data to a server without having to wait for a response. Requests are queued and sent by the browser as soon as possible but -- importantly -- it doesn't delay unloading of the current page or loading of the next. navigator.sendBeacon() is passed a URL and data typically as a string or FormData value. Typically, it could be used when transmitting statistical information, e.g.

navigator.sendBeacon('/log', 'page-unloaded');

The method returns true if the browser successfully queues beacon request. I'm not sure what you could do if false was returned but beacons should not be used for essential functionality and messaging. The Beacon API is supported in Chrome, Opera and Firefox 31+.

Continue reading %What’s New in Chrome 39%




by Craig Buckler via SitePoint

No comments:

Post a Comment