jQuery 1.8 Released

Posted on by

August just got a little hotter, because jQuery 1.8 final code is here! You can pick up the code from jQuery’s CDN:

As usual, the Google and Microsoft CDNs will also have the file soon. Please don’t ask us about when they’ll be there, we don’t know and we don’t control those CDNs! Use our copies directly from the jQuery CDN above if you’re just itching to get started. It’s the same bits.

We don’t expect to get any bug reports on this release, since there have been several betas and a release candidate that everyone has had plenty of opportunities to thoroughly test. Ha ha, that joke never gets old. We know that far too many of you wait for a final release before even trying it with your code. So now there is really no reason to wait, and you can find out if there are any bugs you could have reported earlier.

If you do find a bug, please create a test case on jsFiddle or jsbin and file a bug on our bug tracker. If you’re not sure whether you’ve found a bug, ask on our forum. jQuery core 1.8.0 is compatible with the latest versions of jQuery UI (1.8.22), and jQuery Mobile (1.1.1). Be sure to update those if you’re reporting bugs on pages that involve them.

A Whirlwind Tour of jQuery 1.8

Let’s just recap the big changes in this release:

Sizzle re-architected: jQuery’s selector engine is faster than ever, thanks to a rewrite (well, really two rewrites) by Timmy Willison. Sure, most browsers have querySelectorAll nowadays, but nearly every implementation falls short in one way or another, creating a road full of cross-browser potholes. Sizzle smoothes that road for you. Plus, you may want those useful jQuery selector extensions like :has() with a complex selector or :contains(). Oh yeah, and there’s still IE6/7 support.

Animations re-imagined: Over time, the animation code in jQuery had become kind of messy. Corey Frang took a head-first dive into that swamp and managed to remove most of the alligators, um, bugs. Most of the changes are under the covers, so existing animations should just work (and work better). But there are also some awesome additions to make animations more general and extendable. One notable and very cool feature is the use of the progress callbacks in Promises. We’re still working on detailed documentation, but we do have a draft. Also, here’s an example of the new code in action: http://jsbin.com/odocid/1/edit.

Automatic CSS prefixing: When you use a CSS property, in either .css() or .animate(), we’ll use the correct prefixed property (when appropriate) for that browser. For example, take .css("user-select", "none"); in Chrome/Safari we’ll set the value as "-webkit-user-select", Firefox will use "-moz-user-select", and IE10 will use "-ms-user-select".

More flexibility with $(html, props): In jQuery 1.8, you can use any jQuery method or plugin in the object passed to $(html, props). Before, you could only use a short list of method names, and there was no documented way to add to the list. Now there doesn’t need to be a list at all! Be aware, however, that this can cause the behavior of your code to change if plugins are added later that have the same names as HTML attributes.

More than 160 bugs closed: The Sizzle and animation rewrites in particular provided the impetus to fix several long-standing bugs–some of which have been around for two or three years. Mike Sherov tackled most of the open CSS and positioning issues, getting us down to near-zero bugs there. We also haven’t given up and are still pounding away to eliminate annoying differences between IE 6/7/8 and modern browsers, so you don’t have to deal with them.

Smaller code size: Despite all the code cleanup, new features, and bug fixes, the gzipped file size of jQuery 1.8 is actually a few hundred bytes smaller than jQuery 1.7.2. Size reduction wasn’t our primary goal in this version, but we felt it was important to hold the line on code growth, and we definitely achieved that. Many thanks to Richard Gibson for leading the code-crunching charge across the entire project.

Modularity: If you know your project’s jQuery dependencies well, you can use the new grunt-based build system to strip out parts of jQuery that you know you don’t need. What we’ve done here for 1.8 is really just a beginning, you’ll see even more flexibility as we move to later versions.

The full changelog is available below, in case you’re wondering whether your favorite bug was squashed.

What’s Been Removed

The short answer is “very little”. We wanted to provide a generous notice period for deprecated features that will be removed in 1.9, to give people time to adapt their code. Several of the things removed in 1.8 were undocumented internals that some people have cleverly reverse engineered, but it’s always risky to use undocumented features. Here are the items removed:

$(element).data(“events”): In version 1.6, jQuery separated its internal data from the user’s data to prevent name collisions. However, some people were using the internal undocumented “events” data structure so we made it possible to still retrieve that via .data(). This is now removed in 1.8, but you can still get to the events data for debugging purposes via $._data(element, "events"). Note that this is not a supported public interface; the actual data structures may change incompatibly from version to version.

Deferred.isResolved() and Deferred.isRejected(): Calling N-1 boolean methods to get the state of an N-state variable was getting a bit silly, so we added Deferred.state() in jQuery 1.7 to tell you the state in a single call. So, these two older methods aren’t needed anymore. It’s much more convenient for debugging scenarios where you often want to know the state of a Deferred as a string.

$(element).closest(Array) returning Array: This was a strange signature of the .closest() method intended for use by the old .live(), but not used by any other code as far as we know. Normal uses of .closest() returning a jQuery object are not affected by this signature being removed.

$.curCSS: This method was simply an alias for jQuery.css() from jQuery 1.3 onward. Although it has never been part of the documented API, some external code has been known to use it, perhaps thinking it was “more efficient.” Now it’s “more gone.”

$.attrFn: Yet another undocumented item, used to define which methods could be used in conjunction with $(html, props) signature. Although it serves no functional purpose in jQuery 1.8, we are leaving an empty $.attrFn in jQuery to prevent code that uses it from throwing errors. Fair Warning: This will be removed entirely in jQuery 1.9, so update your code!

Where Credit’s Due

This release couldn’t have happened without the hard work of the talented jQuery Core team: Julian Aubourg (jaubourg), Corey Frang (gnarf), Richard Gibson (gibson042), Mike Sherov (mikesherov), Rick Waldron (rwaldron), and Timmy Willison (timmywil).

Special recognition goes to these jQuery team and community members who supported the Core team with patch contributions during the jQuery 1.8 development cycle: Andy Monat, Robert Katic, Joaoh Bruni, Sindre Sorhus, Oleg Gaidarenko, Yehuda Katz, Timo Tijhof, Dominik D. Geyer, Scott González, Jörn Zaefferer, Matt Farmer, Trey Hunner, Jason Moon, Ben Alman, Jeffery To, Kris Borchers, Daniel Herman, Vladimir Zhuravlev, Jacob Thornton, Chad Killingsworth, Nowres Rafid, David Benjamin, Uri Gilad, Chris Faulkner, Elijah Manor, and Daniel Chatfield.

We’re also very thankful to those of you who took the time to report bugs; we can’t possibly fix a bug unless we know it exists. If you’re looking for an easy way to contribute to jQuery, get to know the bug tracker and help us by creating reduced test cases that clearly demonstrate bugs. Once we can reproduce a problem, a solution usually isn’t too far away. Those test cases become the foundation for a unit test that can prevent the problem from happening when we change code in later revisions.

jQuery 1.8 Change Log

Ajax

  • #8205: JSONP random result is causing memory leak in IE8
  • #8653: jQuery.param outputs "null" and "undefined" in the query string
  • #9399: Deprecate jqXHR.success and jqXHR.error
  • #10285: evalScript rcleanScript replacement fails in IE8
  • #10524: jQuery.fn.load does not merge data parameter with jQuery.ajaxSetup
  • #10944: $.ajax does not always return an object implementing the Promise interface
  • #11013: Deprecate use of Deferred/Promise with sync $.ajax
  • #11402: evalScript function fails with error error 80020101 in IE
  • #11743: jQuery silently ignores errors during script tag ajax request in $.appendTo()
  • #11778: Cached XHR requests should still resolve asynchronously
  • #12122: jQuery.ajax() async deprecate use with $.Deferred

Attributes

  • #11153: jQuery 1.7 Strips Carriage Returns in IE 8
  • #11212: Sizzle.getText converts unbreakable space into whitespace on IE
  • #11547: XML DOM .removeAttr() doesn't remove cased attributes
  • #11962: Standardize getter return values for empty sets.
  • #12127: Clone does not correctly copy checked state in IE10

Build

  • #11767: Support custom build without effects
  • #11789: Update README to describe grunt build system
  • #11856: modularize dimensions
  • #11857: modularize css
  • #11865: modularize offset
  • #11965: Create deprecated.js to contain as much of the deprecated stuff as possible
  • #12059: `grunt custom` should minify – also should add excluded modules to headers
  • #12158: jQuery 1.8rc1 does not work with YUICompressor 1.4.7

Core

  • #10657: Deprecate jQuery#size() in favor of jQuery#length
  • #11290: selector interpreted as HTML
  • #11470: Adding a builtin readyP promise
  • #12018: $(document).ready() fires too early in IE8
  • #12026: Let $(html, props) use any jQuery.fn method

Css

  • #10373: `document.defaultView` => `window`
  • #10394: jQuery.cssHooks.opacity throws exception on non-IE browsers
  • #10413: width, innerWidth, innerHeight, outerWidth, outerHeight are inaccurate for a "box-sizing: border-box" child of hidden parent
  • #10679: CSS3 vendor prefix support
  • #11004: getWH incorrectly removes padding and border width when box-sizing is border-box
  • #11787: Remove jQuery.curCSS
  • #12088: Webkit now returning percentages for more getComputedStyle properties
  • #12148: hide event don't fire when toggle

Data

  • #7579: jQuery.data() truncates numbers taken from data-xxx attributes
  • #10589: Remove $.fn.data("events")
  • #11435: Obsolete test code to remove toJSON from .data's return value

Deferred

  • #11010: Make Deferred.then == Deferred.pipe like Promise/A
  • #11011: Allow traditional options object for $.Callbacks flags
  • #11736: Remove Deferred .isResolved() and .isRejected()
  • #11749: Preserve context objects when multiple Deferred object are passed to $.when()

Dimensions

  • #6724: wrong $(window).height() in mobile safari (iphone)
  • #10877: Make outerWidth/Height a setter
  • #11293: Reading width or outerWidth of empty TDs alters columns width values
  • #11604: Switch $(elem).width(-val) from no-op to $(elem).width(0)
  • #11724: $(document).height() changed in Firefox 12

Effects

  • #7109: animate width starts with invalid width on webkit
  • #7157: Animation callback shows element is still ":animated"
  • #8387: flickering problem with jQuery 1.5 hide/show issue with inline and inline-block elements on webkit browsers
  • #8627: .animate() fails on letterSpacing in IE (regression in 1.5.1)
  • #8892: Callback is raised before objects are shown with fadeIn() and jQuery.fx.off = true
  • #9217: javascript error in IE8 when animating element is removed before animation finishes
  • #9505: animate() issue when mixing percentages and pixels in WebKit
  • #11635: Explicit overflow:auto is overridden by inline overflow:hidden during animation
  • #11755: animate and it aliases should not use :hidden selector
  • #11797: New animation related events
  • #11854: percentage animations jump to end
  • #11971: Animating background-position fails in IE8
  • #11999: Incremental animation on fixed div does subtraction instead of addition in Chrome.
  • #12117: overflow hidden not properly set when animating to 0 height or width
  • #12138: fadeOut doesn't work in Chrome on basic SVG elements
  • #12150: border-spacing property accumulates when rows are shown and hidden

Event

  • #8545: Leak with events in IE
  • #10067: Firing $.ready on document.readyState === 'interactive' too
  • #10895: The doScrollCheck ie hack in bindReady degrades ie7 performance for no reason whatsoever
  • #11101: Deprecate "exclusive" events option from trigger method
  • #11315: Problems with delegate() and :first in nested elements with equivalent classes
  • #11328: Ctrl key doesn't set event.metaKey to true on Windows
  • #11382: Mouseenter doesn't fire on a disabled input element
  • #11500: Bug : "change" event handler not executed when triggered manually on IE7 & IE8
  • #11621: Triggering a event on document doesn't bubble to window
  • #11718: Deprecate .data() events
  • #11719: Deprecate .bind("ready") event
  • #11731: Deprecate "hover" pseudo-event
  • #11733: Deprecate .load(), .unload(), and .error() methods
  • #11764: Allow delegated non-native events on disabled elements
  • #11786: Deprecate .toggle( handler, handler, … ) signature
  • #12203: .undelegate() with no arguments unbinds all handlers from the parent element

Manipulation

  • #8894: appendTo() and alike methods called after clone() returns incorrect jQuery set in IE
  • #10324: Clone does not copy innerHTML of object element in IE9
  • #11231: Append, Prepend, After, Before should accept an array as first argument
  • #11325: Improve domManip/buildFragment/clean
  • #11338: Inconsistent behavior with .replaceWith() and disconnected nodes.
  • #11528: ie8 serialization bug with .html() also hitting html5 tags
  • #11566: node.append et al. does not work when node is a DocumentFragment
  • #11617: Define a $.parseHTML method for creating HTML fragments
  • #11809: Memory leak in .text(val) setter?
  • #11898: prevAll() with a complicated :not() selector returns results in wrong order
  • #12132: IE10 bug when cloning an object element without a parentNode

Offset

  • #10996: Simplify offset()
  • #11823: Remove webkitConvertPointFromNodeToPage

Selector

  • #3778: selector matching issues
  • #5568: Selectors behave differently with comments tags on FF/IE
  • #7596: xpath selector attribute name with brackets [] fails
  • #8473: In IE9rc *[tabIndex] select all elements without tabindex also
  • #8906: .(prevAll('span:has(input,select,textarea)')
  • #9400: Deprecate :text, :radio, :checkbox, etc. selector extensions
  • #9810: Rewrite Positional Selector Logic
  • #10003: Regression/BC break from #6963
  • #10074: Chaining two [] selector with :first not working
  • #10499: :nth-child() inside :has() treated as if outside it
  • #10570: :text selector throws an error in IE7 when there is a cross domain iframe on the page
  • #10697: Sizzle revamp
  • #10799: Inconsistent results with [name="name"] selectors (also breaks .has)
  • #10809: incorrect test using ".activeElement" in the :focus pseudo-class resolver
  • #11109: Sizzle: Expr.relative truncates prematurely
  • #11120: Tabs in some selectors break in IE7
  • #11814: Sizzle's element-rooted QSA strategy (i.e. attaching a temporary id) does not account for comma and other other selector divisions
  • #11826: Explore a parsed caching system for matchesSelector within Sizzle
  • #11902: :not + :contains selectors
  • #11918: :eq selector problem when using tag name with ':'
  • #11959: Add support for :active selector
  • #11961: "Maximum call stack size exceeded" when using jQuery#is
  • #11966: descendant selector
  • #11969: Missing null check when gathering siblings
  • #12054: Uncaught TypeError: Object #<HTMLDocument> has no method 'getAttribute'
  • #12057: Sizzle Regression
  • #12082: .find() POS selector no longer working in 1.8b2
  • #12153: Error occurs in the selector

Support

  • #9385: Deprecate jQuery.browser
  • #11163: jQuery.support.checkClone always true
  • #11249: CSP error in Chrome 18 when loading jQuery 1.7.1
  • #11439: jQuery.support.parentNode used, but not defined any more.
  • #11721: deprecate and remove internal uses of jQuery.support.boxModel
  • #11757: IE 8 memory accumulation in iframes with jQuery 1.7.2
  • #11766: Move jQuery.support to "unstable" status

Traversing

  • #9800: New method: .addBack (supersedes .andSelf)
  • #11539: All version of jQuery don't support .has() on $([text Element].parentNode).has?(other_element)
  • #11543: .has doesn't work on detached elements
  • #11706: `.has()` fails on document fragments
  • #11738: Remove .closest(Array) returning Array

59 thoughts on “jQuery 1.8 Released

  1. h2gc8fgiui33hfu3 on said:

    Still waiting for generator for download separate module. Now jquery is the biggest file on my website and when i split into 15Kb my website will be faster about – 150ms hahah ;)

    ps. greta work bazinga

  2. been testing the RC this week and all has been looking good. really love the custom build flexibility, and hoping that you’ll extend the granularity even further in future releases. have found “-ajax/jsonp” to be a nice way to shrink a little of the ajax code without losing all of it.

    seriously impressive work, can’t wait for v2.0 :)

  3. h2gc8fgiui33hfu3 on said:

    damm scrollTo – plugin not working :(

    eq

    $(‘body’).scrollTo( $(‘.gotoo’) […]

  4. Andray Siletsky on said:

    New version 1.8.0 broke the jquery UI dialog control. Conformation Buttons displayed without text/value.

  5. Daniel on said:

    Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. ~ Antoine de Saint-Exupéry

  6. Mubasshir Pawle on said:

    thats awesome…but still size is quite big
    anyways congratulations…you have done great work

  7. Shadab on said:

    Congratulations on the release . Should have left out IE6/7 support. Would have made the rewrite a lot easier too and code slicker.

  8. Ah, .live() (that was indeed deprecated in previous releases) has been removed? Guess I’ll be switching to .on() then.

  9. Fabio Canache on said:

    was support for $.browser removed in this new release?

    by the way impressive job guys!

  10. Heinrich Thissen on said:

    New version 1.8.0 broke the jquery UI dialog control. Conformation Buttons displayed without text/value.

    The Problem is the empty Function “attrFn” in ver. 1.8.0
    UI Dialog found the empty attrFn and use it.

  11. Hello there. I would just like to report that version 1.8.0 from both jquery.com and Google’s CDNs seems to break several of my jQuery scripts in different sites I run. Some incorporate jQuery UI, some do not.
    Cheers!

  12. Please fix backwards compatibility with jQuery UI, saves a lot of frustration with bugreports ending up being incompatible versions of UI.

  13. Martijn on said:

    Wow cool. Lots of fixes and very few compatibility breaks.

    Are there any of those nice graphs that illustrate performance improvements? (if any) We used to get the nice graphs until something like a year or so ago.

    Also, are there any guides available for plugin-writers that explain what to use and what not to use (and how to use) when a plugin needs to be compatible from, say, jQuery 1.4 and up?
    Currently, I’m working on a plugin that needs to remain compatible with jQuery 1.6 and up, so I should be using isRejected(), since state() isn’t available yet – but if isRejected() is to be removed, I can essentially use neither, or check which one is available (which is iffy and increases my code footprint).

  14. I like that you guys have a CDN for 1.8. I see that Google has now updated their URL. With Google’s URL it is very flexible:

    Last week this url gave 1.7 but now it automatically gives 1.8:

    ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js

    however if you specify jquery/1.7/jquery.min.js then it gives you the latest version of 1.7.

    If you change that to jquery/1.7.1/jquery.min.js it gives you the latest (sub) point release of 1.7.1

    Would you guys be willing / able to implement such a URL structure for your hosted / CDN version of jQuery?

  15. A little confused with the removal of $.load()? Documentation for $.load doesn’t mention anything about being deprecated (should it?). Does this mean $(window).load(function() { }) is deprecated? What would be suggested instead?

    I’ve spent the past hour or so going through some of these fixes, hope it doesn’t break any of my code :)!

    Updating jQuery and jQuery UI now =) woot woot. Great job everyone!

  16. Valoukh on said:

    I’m not sure if this is a relevant comment for this page as it’s not necessarily a JQuery issue but I’ve just noticed that this new version seems to break the FusionCharts XT plugin. I can’t see anything obvious in the above change log but the charts work with JQuery 1.7.2 but not 1.8.0 (the charts don’t use JQuery but simply loading JQuery causes the charts to not work correctly).

  17. Ic3Ninja on said:

    @outerHeight.complainers

    What is so wrong with using the word “true” instead of the number “1”? Yes I understand the argument that “true” and “1” in boolean should both resolve the same and it should be something that isn’t specifically looking for the literal string “true” instead of any value that equates to a “true” statement, but if one works and the other doesn’t…just how many lines of code do you have on your site and how many times are you using .outerHeight(1) in your code to not be able to simply make sure you put in “true” instead of “1”? Then cry that it “broke your site”? All over one minor modification instead of multiple incompatibilities with the 1.8 jQuery update? Seriously now…thank you for bringing up the fact that it is doing that, but to claim that it “broke your site” – the one function out of the many that are apart of jQuery – instead of a cascade of failures stemming from multiple functions causing errors…that is just foolish.

    The wrong character in the wrong spot can cause an error on the page, but fix that character and poof…everything’s working again. That isn’t “breaking the site”, that’s a part of any coding process which is why you code, test, check if debugging is needed, debug if necessary, test again, rinse and repeat till no bugs, then load to the site. That is coding basics for ANY programming language. Now when the error causes your to have to reload everything on your site because correcting the character (this case “true” vs. “1”) and reloading the page doesn’t allow the page to display, then having to resort to removing that line of code all together to allow the site as a whole to function even if that line of code is not incorporated in any other page you have loaded on your site…THEN you can spout that it “broke your site” and I will humbly accept that statement. Till that time, please…can we be a little professional here and not point fingers, instead just simply show the error, what caused the error, and a suggestion on fixing the error so…wait for it…the error can be fixed and then you can go on your merry little way?

  18. DerWaldschrat on said:

    I do know that this section is not for bugposting or fixing or something like that.
    But it seams that outerHeight tries to set a value to the jQuery-collection when a number is passed, although this is not a documented “feature”, so the object which is returned is the jQuery collection itself…
    Just use !0 as a safe shortage for true as uglify-js does.
    DerWaldschrat

  19. Tomás Girardi on said:

    About: $(element).data(“events”) Removed

    What should be the correct way of copying the event handler from one element to another?

    I’m using this workaround – getting the event handler from the object and attaching it to another one – and it’s working, but will stop to work if I update to 1.8. Yes, I’m part of those people who “have cleverly reverse engineered…” but now I don’t feel so clever as I don’t know if there is a correct way of doing what I’m doing, but in a standard non-workaround way :-(

    Please help. Thanks in advance

  20. Danny Fardy Jhonston Bermúdez on said:

    “Sizzle re-architected: jQuery’s selector engine is faster than ever, thanks to a rewrite (well, really two rewrites) by Timmy Willison. Sure, most browsers have querySelectorAll nowadays, but nearly every implementation falls short in one way or another, creating a road full of cross-browser potholes. Sizzle smoothes that road for you. Plus, you may want those useful jQuery selector extensions like :has() with a complex selector or :contains(). Oh yeah, and there’s still IE6/7 support.”

    Results:
    $(“#element1, #element2, #element3, #element4, #element5, #element6?).show(); is slower in IE7 with jquery-1.8.0.js than jquery-1.7.2.js

    Please help. Thanks in advance.

  21. CodeTech on said:

    IN response to Ic3Ninja’s rant:

    I have sites and web apps with together hundreds of thousands of lines of code. When a change comes along that breaks existing code, that requires me to step through everything and figure out why pages aren’t loading or functionality is broken. That is time, and time is money.

    My option is to forego any improvements I might be wanting from newer versions until I can find the time to go back and figure out what change broke my site. See why people get upset?

    Your rant is only applicable to people doing small sample sites. Real production work doesn’t always allow enough time to go single stepping through code due to someone else’s changes.

  22. Maybe people wouldn’t be complaining that their websites broke after the upgrade from 1.7 to 1.8 if jQuery used semantic versioning where the major version (the x of x.y.z) must be incremented if any backwards incompatible changes are introduced to the public API. Just a thought. See: http://semver.org/

  23. I can’t seem to get the dialog to pop up. If I use the combination of jquery 1.6.l3 and jquery ui 1.8.23, it works. But if I use jquery 1.8.0 and jquery ui 1.8.23, it doesn’t.
    The main screen was grayed out, but the dialog window doesn’t come up.

    HELP!