As of changeset #5985 (what will ultimately become 1.3), jQuery no longer uses the jQuery.browser object to adjust functionality based on the browser’s UserAgent. The jQuery team has also deprecated this method of doing browser detection and now advocate functionality detection as they now do in the core.
This detection takes place in the new jQuery.support object. The idea is that instead of maintaining a complex set of browser detection code to figure out if a browser’s client is Internet Explorer just to determine jQuery’s approach to adjusting an element’s opacity, jQuery now implements tests to test for that functionality.
To demonstrate. Prior to this changeset, jQuery would do this to figure out how to handle opacity:
// We need to handle opacity special in IE
if ( name == "opacity" && jQuery.browser.msie ) {
ret = jQuery.attr( style, "opacity" );
This is problematic for a number of reasons. jQuery will have to keep a running tally of what browsers handle things different ways and which older browsers gain new functionality in the future. With all the new browsers and their varying levels of support of different sub/supersets of HTML and CSS, this becomes an unwieldly task.
The scalable approach is what jQuery team and John Resig have implemented in this new revision. In order to determine what to do in regards to opacity, the new jQuery.supports object can test any browser to know if it supports it correctly or “weirdly” in which case they can take a different approach. Here’s what the code looks like now:
// We need to handle opacity special in IE
if ( name == "opacity" && !jQuery.support.opacity ) {
ret = jQuery.attr( style, "opacity" );
The actual support object and detection code are surprisingly concise—less than 100 lines of nicely formatted JS—and can be found in the new support.js.