Firefox 6 released: Bliss for Javascript and web developers

Today Firefox 6 got leaked for all major platforms, Windows, Linux and Mac that is. Well, sort of leaked actually. The executable package was available for some time here , only for the ftp access to get password restricted soon after.However, this didn't stop other ftp servers from mirroring firefox all around the globe: Grab it from Softpedia one of over a dozen servers. Interest in the version-frontrunner, Firefox 7 has rekindled as well, and even Firefox 8 - which is supposed to outline the path, developers at Mozilla plan to take). Firefox 7 is said to focus on reduced memory consumption, improve upon the current memory footprint by as much as 30 percent "for many users.". Honestly, I wouldn't hold my breath, though an archievement of half of that goal (15%) would certainly count as success. ( I intend to make a comparison chart once the final version is released. ) The full list of improvements reads as:
· The address bar now highlights the domain of the website you're visiting
· Streamlined the look of the site identity block
· Added support for the latest draft version of WebSockets with a prefixed API
· Added support for EventSource / server-sent events
· Added support for window.matchMedia
· Added Scratchpad, an interactive JavaScript prototyping environment
· Added a new Web Developer menu item + moved development-related items into it
· Improved usability of the Web Console
· Improved the discoverability of Firefox Sync
· Reduced browser startup time when using Panorama
· Add-ons Manager with Plugin Check: Check that your plugins are up-to-date
directly from the Add-ons Manager
· Improved Panorama Groups: Reduces browser startup time by only loading saved
tab groups when you use Panorama
· Improved Address Bar: Highlights the domain name of the website you’re visiting
to make it easy to identify where you are online
· Streamlined site identity block
· The Scratchpad: Quickly build and test JavaScript snippets in the browser
· Support for Web Sockets with a prefixed API
· Moveable Web Console
· New Web developer-specific menu
· Window.matchMedia API
· Support for server-sent events
new in Firefox 7.0a2 Aurora - July 8th, 2011
New in Firefox Aurora:
· Performance Enhancements: Faster startup time on Mac, Windows, and Linux
· Optimized Memory Use: ◦Improved memory management
· The JavaScript garbage collector runs frequently to free up more memory
when Firefox is idle
· Firefox Sync: Bookmarks and passwords now sync instantly
· Enhanced Font Rendering: Fonts are rendered clear and sharp
New platform features and developer tools:
· Telemetry: Users can opt-in for automatic memory usage, performance testing
and reporting to help improve future versions Firefox
· Web timing spec: Measure performance characteristics of websites as users
experience them
· Azure Direct2D for Canvas: Canvas-based animations on the Web are
dramatically faster
· Support for CSS3 Text-Overflow: ellipsis: New and more elegant way to
display text content that has overflowed its given layout area
Download FF7 here Over the coming hours I will present code examples of the possibilities which opened up with the support of Websockets, Window.matchMedia, Scratchpad and finally server-sent events. (Websockets have been present since the developer version of Firefox 4, but due to security problems were redacted) Some highlights of the new version for developers are: Server-sent events will permit servers to cause DOM events and provide or add data to these DOM-event-associated elements. about:memory now gives more detailed information about the individual memory footprint, similar to what has been present in Chrome since version 4. Finally the API for handling binary data has improved such that it can read data via XHR2 as Blob (Binary large object) or Arraybuffer by using the function FileReader.readAsArrayBuffer() . This allows increased isomorphic data handling between the server database and the client, improving upon speed in both execution and development. Javascript's indirect new addition are weak references, which is one of the reasons on the memory improvement claims.
A weak reference is a special object containing a object-pointer, but does not keep that object alive.
This means the garbage collector is free do to its routine destruction. Mozilla provides details on the implementation. An example is provided directly in wikipedia for Java and pasted underneath.
 
import java.lang.ref.WeakReference;

public class ReferenceTest {
public static void main(String[] args) throws InterruptedException {

Student s1 = new Student(1);
System.out.println(s1);
WeakReference<student> ws = new WeakReference<student>(s1);
System.out.println(ws.get());
s1 = null;
System.gc();
Thread.sleep(1000);

System.out.println(ws.get());
}
}

class Student {
public Student(int id) {
this.id = id;
}

int id;

public String toString() {

return "[id=" + id + "]";

}
}
As for javascript look here, and here, as well as directly from mozilla which acts as the most informative source. Mozdev may help you as well. One application of weak references isimplemented in the form of "Weak Maps":
"The experienced JavaScript programmer will notice that this API could be implemented in JavaScript with two arrays (one for keys, one for values) shared by the 4 API methods. Such an implementation would have two main inconveniences. The first one is an O(n) search (n being the number of keys in the map). The second one is a memory leak issue. With manually written maps, the array of keys would keep references to key objects, preventing them from being garbage collected. In native WeakMaps, references to key objects are held "weakly", which means that they do not prevent garbage collection in case there would be no other reference to the object." Source
LihatTutupKomentar