Firefox 4: A Developer’s Perspective

Firefox 4: A Developer’s Perspective

Right on the heels of Internet Explorer 9 arrives the much vaunted, latest iteration of Firefox 4. The release has been a success so far, with over 7 million downloads in the first 24 hours and over 40 million till date. Today, I’d like to give you a quick overview of the changes from a developer’s perspective — I’ll be skipping the new UI and the other whizbang features.


More HTML5

Tutorial Image

A new rendering engine, Gecko 2.0, is under Firefox 4′s hood.

A new rendering engine, Gecko 2.0, is under Firefox 4′s hood. For the most part, as expected, it offers great support for standards-oriented web development. Also at play is a brand new HTML5 parser that defines how your HTML code is turned into a web page.

As a result, you get improved performance, from innerHTML calls specially, the ability to include SVG inline in your code and overall stability and responsiveness due the parsing algorithm being run on its own processor.

More improvements from a HTML5 development standpoint are the more mature support provided for HTML5 forms and the Audio API. Support for the newer markup elements and attributes will significantly decrease the JavaScript code you’ll have to write to provide equivalent functionality. Think easier validation — your form elements will require zero JavaScript to glue the validation rules to it.


WebGL

Tutorial Image

WebGL is a standard that is based on OpenGL ES that lets you perform 3D rendering on the web.

WebGL support has been pretty nascent in previous versions of Firefox — only the nightly test builds featured support for the technology. Firefox 4 ships with full support for the platform.

If you’re wondering, WebGL is a standard that is based on OpenGL ES that lets you perform 3D rendering and other assorted manipulation through the canvas element. The API itself is more low level than you’d exect providing you with enormous flexibility and power. If something can be done on a desktop, you can do it on the web too!


Hardware Acceleration

Tutorial Image

We reduce the workload on our general purposes CPUs by letting much more parallel, and capable, GPUs handle specific computations.

Hardware acceleration is offloading tasks that are typically handled by the software to the hardware wherever possible. In our scenario, we reduce the workload on our general purposes CPUs by letting much more parallel, and capable, GPUs handle specific computations, thus eking out better performance. Both the task of rendering the page content and then compositing it are accelerated though different APIs are used on different platforms.

On Windows, Direct2D is used for content acceleration, including canvas manipulations and drawing, while Direct3D is used for compositing acceleration. On OS X, Quartz handles the former while the much more open OpenGL takes care of the latter.


JägerMonkey JavaScript Engine

Tutorial Image

JägerMonkey is an advanced, optimized version of TraceMonkey, the JS engine in Firefox 3.6

In accordance with developer expectations, Firefox boasts a newish JavaScript engine under the hood — JägerMonkey. An enhanced version of TraceMonkey (the JS engine in Firefox 3.6), JägerMonkey adds many more optimizations to the mix resulting in startling improvements in performance.

Newer and cleverer optimizations like a per-method JIT approach performs more aggressive native compilations resulting in performance that’s a lot better than the competition. To give you an example, Firefox scores roughly six times better in the V8 benchmark and thrice as fast in the SunSpider benchmarks compared to Firefox 3.6.

Overall, JägerMonkey has brought back Firefox in the race for supreme JavaScript performance.


CSS Transitions and More

Firefox finally supports CSS3 transitions and transformations.

One of the notable additions for a front end developer is extensive support for CSS3 transitions. While the other browsers have boasted CSS3 transitions for a long time now, Firefox has been sorely lacking. The latest version provides a nearly complete implementation of the specification.

CSS transitions provide a pure-CSS method to animate changes between CSS properties. Transformations like scaling, rotating and skewing are on tap for you too! You can even use these transformation within transitions to create nifty effects. Remeber those jQuery snippets you used to fade items and colors, in and out? For our intents and purposes, they’re pretty much redundant — a few lines of CSS is all it takes now.

The newer features include:

  • Support for touch properties.
  • Addition of -moz-any to group together structurally relevant selectors.
  • Computed values through -moz-calc allowing you to define values through mathematical expressions.

Even though it has taken the Mozilla team a while, the mere action of added support makes it easier for web developer to embrace these new technologies.


WebM

Tutorial Image

Firefox now ships with WebM support greatly boosting both its ability to consume video content on the web and WebM’s market share.

Even though developer nightly builds have been able to play the format for a couple of months now, this is the first official release to provide support for the format.

If this topic makes your head a little fuzzy, I suggest reading my earlier article on video codecs on the web where you can find further information on this topic. Suffice to say that by adding WebM support, Mozilla has strengthened its standards based idealogy and simplified life for its users in a single move.


IndexedDB

IndexedDB saves data as JSON formatted documents.

IndexedDB is Mozilla taking a radical, more usable route compared to other browsers by opting to go for the NoSQL approach. Remember that most other browsers use the Web SQL API wherein developers write SQL to obtain information stored in SQLite databases.

IndexedDB saves data as JSON formatted documents and lets you access the information it holds through a simpler, non-SQL API. The end result? Much easier syntax and a more standardized API that insulates you from the nuances of the implementation while still providing you with enormous flexibility.


Web Console

Tutorial Image

While it won’t replace Firebug, the new Web Console is incredibly handy.

The new Web Console replaces the Error Console from previous versions. While it won’t replace some of the advanced tools like Firebug, it comes eminently handy when you’re poking through the innards of a site or an application.

The console can be opened with Ctrl+Shift+K [Cmd for the fruity hipsters] and comes bundled with:

  • a command line JavaScript interpreter that lets you execute JavaScript in real time.
  • a logging mechanism that logs CSS and JavaScript errors. Network requests are logged too letting you access information about the request. Headers, responses, everything’s game.
  • an object inspector to examine any JavaScript object that resides in the browser’s memory.

Better Typography

Tutorial Image

Support for OpenType now lets you play around with more advanced settings like kerning.

You can now use OpenType, a open font format, giving you access to a much more varied palette — you’re no longer limited to web safe fonts.

While it may sound boring, support for OpenType ushers in a slew of features. You’re able to modify kerning, ligatures and get automatic fractions among many others.

One more point to make note of is that if your site is non-English, the new Firefox engine renders your content without any hitches or visual hangups. And with the exponential rise in non-English web pages, this features helps both the developers and the end users.


That’s a Wrap

The newest iteration of Firefox is quite the leap over the previous generation with a number of additions and improvements aimed at developers and designers. JavaScript junkies too have been taken care of by the improved performance courtesy of the new engine, better HTML5 and CSS3 support as well as a much more robust set of tools.

So what do you think about Firefox 4? Love it? Hate it? Let us know in the comments and thank you so much for reading!

Siddharth is Siddharth on Codecanyon
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://www.wesbos.com Wes Bos

    Really excited to see the fast adoption of this browser. Looking forward to seeing a bunch of mashups using the audio API

  • prakash

    All is awesome and im using it but great to know specific details excpet one thing( hope to see soon) . i looked that it doesn’t support css3 3D perspective like safari which will help me in building my website to use slide show more awesome way.
    Im right experimentally. is it so?

  • http://www.brettjankord.com Brett

    I updated my work computer and home computer to FF4.0
    I’m hoping Mozilla continues to encourage 3.5 and 3.6 users to update to 4.0.

  • http://www.logic52.com Shane

    Looks good so far, I just wish all browsers would use the WebKit rendering engine, it has a ‘slightly’ better performance with transitions. That ‘slightly’ makes a whole load of difference though.

    Does anybody know whatever happened to X3D?

    • edwinhollen

      The Mozilla rendering engine (Gecko) and the Webkit rendering engine are limited to hardware performance when it comes to 3D acceleration, especially with the new WebGL. I have found that Gecko is an extremely solid rendering engine, whereas Webkit isn’t so solid (see the rendering differences between Chrome and Safari), but is a bit more versatile.

      It all comes down to speed and support. If developers aren’t going to start using HTML5 and CSS3, then users on either browser won’t see any major differences anytime soon.

      Developers, let’s step up and and really push these new technologies to the limit!

      • Flavio

        Don’t agree much. Yes, I like to see the web moving forward but not all kind of websites need this kind of technology, in most cases it would be just like putting the hand in a snakes’ nest. I can think of social web apps and generally apps for the masses for a casual use to employ this kind of tech. They use it at home and they will want to have the same kind of “desktop” experience on corporate intranets and such. You can think making marketing websites to employ new tech for the added visual impact, but you’ll have to have a fall back for all the others, but i guess it’s the kind of project you can easily convince to charge more. But on corporate or governance level, you have to stick with the old.

        Also to consider, support to these different specs is fragmented, it’s suicidal to push too hard, you have not only to cover for all last-gen browsers, but fallbacks to the “good ‘ol” xhtml. And how could you convince charging more to small businesses that merely understand the advantages of a website for a website they probably don’t understand/don’t see the most evoluted features?

  • Purple

    I use FF mostly for my development needs (mostly due to FireBug).

    I love how fast V4 is but I have to still restart the browser a few times a day because of how much RAM it grabs. When opened, it’s at about 200mb. After about an hour of extensive use, multiple tabs… the size goes up to about 700, slowing things down. Anyone found any solutions or have suggestions?

    • Mark Sinkinson

      Agreed! I use FF4 only for Firebug, but the horrific memory hog puts me off using it for anything other than AJAX testing.

      Interestingly Chrome (my current favoured browser) open up a new memory process for each tab opened (normally about 26Mb each), whereas FF4 runs at 700-800Mb even with only 1 or 2 tabs open. Sort this out and I’ll use it more often

      • http://www.normansblog.de/ Norman

        those numbers are just wrong. check your extensions or start a new profile, that should help to improve speed and reduce memory leaks

      • tadhg88

        Agreed again, multiple restarts required daily but stick with it because of firebug’s excellence!!!

    • Purple

      Anyone else out there experiencing this, I disabled YSlow and Pagespeed and am getting a LOT better performance. I have been using it for two days now with multi tabs and tests without a restart, at around 250Mb. Maybe try disabling some other extensions and see if that helps.

    • Ahmed

      Well, that never happened to me even that i use more than a 35 extensions and in a use more than a 30 tabs a time (sometimes more than a 50) and it uses a little bit of memory
      P.S try using memoryfox it will helps a lot.

  • w1sh

    You guys decide not to do April Fool’s this year? Hm?!

    • kwight

      Check out the Tuts+ Solid Gold Bundle…

    • Purple

      Yeah, this year they decided to do the “Solid Gold Bundle”. Awesome deal! Check it out on top of this page.

  • http://www.doctormalboro.net DoctorMalboro

    Nice April Fool’s joke…

  • http://dagrevis.lv/ daGrevis

    I love all that’s under the hood. I hate new UI… it’s so ugly!!

    • http://shaneparkerphoto.com Shane Parker

      daGrevis, you can customize the UI as you please. Personally, I only tweaked it a little and I love the new UI. It’s very clean and easy to use. Here’s how mine looks customized: http://shaneparkerphoto.com/photo/misc/firefox_bar.png

      FF4 is a lot faster too. As far as it eating up RAM, I just let it do it’s thing. OSX is very good about managing memory between apps and since I have a ton of RAM, I’m fine with apps gobbling it up so that they run faster.

      Overall, I’m very happy with FF4.

  • Flideli

    While it won’t replace Firebug, the new Web Console is incredibly… useless ! It’s too late, webdevs use Firebug, that’s all…

  • Yusuf

    i love the new ui..

  • Dave

    Looks like Firebug still has some work to do for FF4. The “debugger;” command no longer fires up the debugger when encountered in your Javascript, and the the “Script” module no longer presents the names of dynamically loaded js files.

  • http://www.cyberstream.us Eli Mitchell

    I like how Firefox 4 has changed only because it is becoming more like what Opera has been for a while. CSS3 transitions & transforms, minimalist UI, pinned tabs are all things Opera has had. There are a few main UI elements that are nearly plagiarisms of Opera’s UI – like the main dropdown menu, the dropdown menu displaying security info when you click on the favicon in the address field, “pinnable app” tabs (called web panels in Opera; You create them by dragging a tab onto the menu panels toolbar. Opera also has the basic tab pinning feature), etc.

    Opera also has additional features that I love like tab stacking, mouse gestures, page previews when you hover of tabs, the speed dial, supports CSS3 better than most browsers, has excellent HTML5 support (http://wufoo.com/html5/), has the Turbo feature which speeds up loading, has an extremely customizable settings and interface, you can personalize it even further with Opera’s integration with My Opera, etc.

    I rave about Opera as much as I can because it has the smallest market share of any other major browser, but I like it the best (along with millions of others!). People need to know what they’re missing. Even if it just means giving Opera one try.

  • kierzniak

    Everything is great beside that ff4 with all my addons is simply slow. I was BIG fan of ff but compering to the chrome ff4 is a cow. Chrome dev tool i very similar to firebug so it wasn’t problem to me to change browser. Matter of habits.

  • http://www.stenvdb.be/ Sten Van den Bergh

    Firefox 4 has a lot of great improvements, but some serious flaws as well, from a developers view I think. I develop quite a lot in Flash. In Firefox 4, when you resize a full Flash website, the screen is white. Never seen this in any other browser.

    So like I said, there maybe are great improvements, but a bug like this is a serious downside. I really hope this gets fixed in an update soon.

  • Andy

    Firefox 4 just seems to crash on me with windows XP. And doesn’t let me use spaces on OSX.
    Just annoys me… That is all..

  • Jose Perales

    Really Disappointed that Firefox 4 does not support ‘ input type=”range” ‘ nice feature of HTML 5 that is very useful for touch app.

  • Jose Perales

    Really Disappointed that Firefox 4 does not support nice feature of HTML 5 that is very useful for touch app, opera safari and chrome have it.

  • Clockturn

    Yet most of its CSS3 properties still use the -moz- prefix, thus forcing us to use regular properties and then the -moz- variant as well. It’s a niggle but it’s still annoying that Firefox is the only browser I have to reach out to at all when developing. This coupled with the giant RAM usage with even a couple of tabs discourages me from using it, since I’m more than happy with Chrome’s debugging tools (not to mention that Firefox’s new UI is largely cloned from Chrome & others, and doesn’t feel consistent to me – it’s half native and half custom rather than Chrome’s full-custom approach).

    It’s also slower to start up and load pages than IE9, with only the barest of plugins loaded. Frankly, the performance of Firefox 4 leaves much to be desired when compared to its prime competitors.

  • http://atinder.com atinder

    i just downloaded firefox 4 yesterday and i am loving it,its very cool :)

  • http://hackstipsandtricks.blogspot.com/ Tushar

    That’s what we call a modern browser. But need to improve more.

  • Mike

    Finally better support for HTML5! FTW!

    http://html5-showcase.com/

  • http://www.learneveryday.net arifur rahman

    Nice article again. Google chrome also have some new extension which is use full for you.

    Google Chrome also going faster , and increase market place.

    Google Chrome Extensions Enable You to Do More Work in Less Time

    http://learneveryday.net/browser/google-chrome-extensions-enable-you-to-do-more-work-in-less-time/

  • http://www.serprisedesign.co.uk Kevin

    Great roundup, I have recently installed 4.0 and am very impressed. Great article =)

  • http://www.mightymeta.co.uk/blog/ James Brocklehurst

    The UI may be more clunky than it’s competitors, it may hog more memory and not be quite so fast, but I’ll be sticking with Firefox simply because of the available add-ons for developers. There just isn’t the range or quality there for other browsers.

  • http://www.alessandroberlato.com Alessandro Berlato

    Firefox 4 is a long-awaited step ahead for this browser.
    New features are really good!

  • http://kamarkecil.com Arif Riyanto

    Nice article, I really love Firefox 4 :)

  • http://www.isotopon.com EL

    I am still a bit skeptic for the new version.

  • http://www.stevendavisphoto.com Steven Davis

    After developing daily on FF4 since it was released, I’m not that happy with it. It’s highly unstable, uses a lot of memory, and crashes more often than FF3.6. I’m thinking of switching to Chrome for development.

    • http://threadbarecanvas.com Siriquelle

      I use chrome for development every day and find it is very stable and responsive.. I think its a Firefox killer I’m afraid.

  • http://www.jauhari.net/ Jauhari

    It’s look like WebGL is the most interesting thing ever in this year

    • http://igambar.com iGambar

      wes mboten kang mas… LOL

  • http://www.logandesigns.co.uk Mark

    I’m gonna go and download it now and give it a go

  • http://pixelflo.net Pixelflo

    Too unstable at the moment. Has already crashed many times during the short time i’ve been using it

  • http://benlwilliams.com Ben

    Has anyone eles that uses a Mac found the same bugs that I have? Sometimes, when clicking on the firebug button in the status bar area, it forces a drag. Also It completely ignores opening more than one window. Tabs are fine, but It will not show more than one window for me. Nothing happens when I go to file > new window or right click and choose “open in new window”.

  • http://bateru.com/news Larry Battle

    I’m really impressed with the improvements that Firefox has made.
    The best shocking feature to me is the new built in console. It shows a lot more useful information than the past.
    Side note.
    Even though the developers spent a long time developing this great product, they still released it for free.
    So it’s disappointing to hear people complain about freeware software when you get it at no cost.

  • http://www.16i.co.uk Thomas Morris

    All the new browsers coming out right now are really enhancing the web and the sooner people start using them, the better I say.

  • http://www.nouveller.com/ Benjamin Reid

    I can’t believe I haven’t downloaded this yet but it’s looking great, nice write up Siddharth.

  • http://www.pixelstadium.com Cardiff Web Design

    Great stuff, thanks for sharing.

  • http://www.creativemonster.net Dan

    Just downloaded and am finding it needs a couple of tweaks to get it running 100%. I still prefer Chrome though.

  • http://www.helloeverything.co.uk Dave

    Really pleased Firefox 4 supports CSS3 transitions and transformations.

  • Sleeman

    Dear net.tuts team , did you notice whats happening to you newsletter section at Firefox 4 ?!!
    its broke down .
    can we know why ?

  • http://twitter.com/gemmaweirs Gemma

    I use Chrome as my primary browser, and FF for development. I used to use FF3.5 for general browsing as well as development, but I got tired of the crashing, the slowness, etc, so I switched to Chrome as my main browser.

    At the moment, I have Chrome open, with 2 tabs and 6 active extensions. Task Manager shows 12 processes open for Chrome, ranging from around 2,400k to 66000k memory.

    I also have FF4 open. Similar deal, with 2 tabs open (same websites) and 5 active extensions. But I have 8 plugins too, mainly for media. In Task Manager, FF4 has one process open, and it averages out at 146,700k.

    The truth? Both browsers are memory hogs. So I’m not testing FF4 on the basis of how much memory it eats up. I’m more interested in how easy it is to use, how fast it is, and how stable it is.

    So far, it has been rather intuitive to use. Obviously it’s fast because it’s new. FF4 hasn’t crashed so far.

    But, I haven’t seen anything that would persuade me to switch back to FF4 for my main browsing needs. Chrome still caters to my general browsing needs very nicely so I’m comfortable where I am. Having said that, I will be using FF4 for my development work, of course.

  • Jim

    FF4 has HUGE memory leaks at the moment. It brings my system to a halt after an hour or so. It is unusable in its present form.
    If you browse Mozilla’s support area and the web, you see that many folks are experiencing these memory issues. I’m very disappointed with Mozilla for releasing FF4 with memory leaks.

  • Alaa

    The greatest browser ever, i enjoy it.. i just cant imagin how my life w’d be without Firefox !

  • http://bachuk.com alex

    FF4 is very good browser and firebug is still my tool of choice. But I wish all the browsers have Chrome’s auto update built in, so we (developers) don’t have to worry about supporting outdated browsers.

  • Erhan

    In firefox 4 xul support is also removed. Thus if you have sites developed using xul avoid ugrading.

  • http://html5andmore.info Andrea Barghigiani

    FireFox is the best browser! (IMHO)

    Has great support, loads of extentions and now… Even better engine e JS performances! What else do you need? CSS3 Transitions? Form Validadion?

    It’s got ‘em! Since the new version it’s back as my “only” browser (before was a bit hard decide which for it’s performances…).

    Anyway, I really enjoyed this post, and I would like to translate it into my own language (italian) to serve your amazing work to my community as well, it’s goin to be ok with you?

    Obviously all credits!!!

    Keep up the amazing job guys!

  • http://thinkstylestudio.com Theron

    Yeah! I do agree with the previous comments made. One thing will be to see how quickly and how many people actually adopt it. Some time the best technologies die out due to people not attaching on to them. Myself I’m using it but i can only use it for certain things as some of the plugins i’m dependant on don’t work with 4 yet.

  • http://www.w3resource.com Ritwik

    Of course Firefox 4 has more things to offer to web developers than it’s ancestors. But I would like to mention that add ons are also required to be made compatible with this latest version of Firefox. For example we use Spell Checker (developed by Gourang) a lot for checking spelling mistakes in our website. But the add on is not available for Firefox 4 as of this writing.

  • Flavio

    I’m not a developer, just designer, can anybody clarify to me the implications of a different database approach from FF to the competitors? As it is written in the article, it makes me think it’s maybe not compatible with “standard” approach, is it or nothing changes? Because who cares about performance if service wouldn’t be guaranteed to anybody?

  • http://www.fraserbathrooms.co.uk Bathrooms Edinburgh

    i think FF4 and Chrome are trying to make the same steps. the get better but I dont think that hardware ac is a big step forward

  • http://www.ecoenrg.com ecoenrg

    I still prefer the old firefox…They changed the UI just like Ubuntu changed their and still can’t get used to all this new “simplified” interface