Sunday, October 17, 2021
More

    What’s New jQuery Use?

    Must Read

    Programmerhttp://www.improgrammer.net
    We started this site to inspire young minds to motivate and encourage them towards Programming Language. In this site you will get programming tutorials, tech, programming facts, programming fun and programming blogs.

    jQuery, the world’s biggest JavaScript library to date, has been a windfall for a lot of us web developers out able. From the time of its basic release in 2006 till today, a lot of us web developers have contained this wonderful library in our enterprise to make our life easier.

    show() and hide()

    Update: jQuery had tried a new application in alpha, but have seized that change in the 3.0 beta.

    With the 3.0 beta, there’s now enhanced performance for covering many elements. The jQuery team made the demo available here. One of the searches revealed this result:

    Test runner
    Test runner

    The jQuery 2.0 version was up to 97% slower!

    In inclusion to this, another implied way to go about the display and hiding aspect is to use addClass()and removeClass() to control clarity. Or we can call hide() on the item during the ready() call.

    A quick sample::

    Can u see
    Can u see

    click me
    click me

    Nomenclature for .data() Key Names

    The jQuery team exchanged the implementation.data() to closely match the HTML5 dataset specification. If the key in the data-* attribute contains a digit, the digits will no longer participate in the alternation. Consider this example:

    With jQuery 2.1.4:

    jquery
    jquery

    The console window does not show the object.

    With jQuery 3.0.0:

    jquery 3
    jquery 3

    The key is reformed to foo-42-name as digits do not aid in the conversion to camel case now. Hence, we get the amount in a console. The fiddle is available at http://jsfiddle.net/nWCKt/25/. You can change the jQuery adaption to see the changes.

    Similarly, if we want to act all the data using withdata() no clash, the number of arguments will change in the two interpretation of jQuery if any of the key names of data-* attributes had a digit directly after the hyphen (-), like in the above case.

    HTML:

     JavaScript:

    In jQuery 3.0, this would reveal the object {foo-42Name: “name bar”, foo-42Yes: “yesbar”}. But in an earlier version, it would show a blank object {}.

    width() and height() return decimal values

    Some browsers return subpixel code for width and height. jQuery now returns statistics values for.width(), ,.height() .css(“width”), and whenever.css(“height”) the browser supports it. For users looking for subpixel precision for crafting web pages, this may serve as good news.

    .load(), .unload(), and .error() methods are removed

    These methods which were object earlier, have now been taken out from in jQuery 3.0.0 alpha. The recommended way is to use to.on() handle these events. Short example:

    HTML:

    JavaScript:

    jQuery Objects are Iterable Now

    Iterating over jQuery objects is a cinch now, using ES2015 for-of. So, you can use things like:

    jQuery Animations Now UserequestAnimationFrame API at the Backend

    All modern browsers now backing requestAnimationFrame (status here:http://caniuse.com/#search=requestAnimationFrame). With its popular support, jQuery will use this API when performing an action. Advantages include smoother activity and less CPU-intensive animations (hence, saving battery on mobiles).

    Enhancement of .unwrap() Method

    .unwrap() method, which lets you expel the parents of the mated elements from the DOM, did not use to take parameters earlier. This could be an argument if someone wants to unwrap basis a status set on the parent.

    With jQuery 3.0.0 alpha, .unwrap() accepts the jQuery selector parameter to handle this.

    jQuery.Deferred Updated to be Promises/A+ Compatible

    A promise is a conditional result of an asynchronous operation – it is an object that assurance to deliver a result in future. The primary way of relating to promise is through the methodthen, which rosters callbacks. Using Promise for asynchronous work in JavaScript is becoming increasingly popular these days. Promises/A+ is an open standard for interoperable JavaScript promises. (For more info, check out this link: https://promisesaplus.com/)

    From the jQuery documentation, the Deferred object is a chainable utility object conceive by calling thejQuery.Deferred() method. It can storage multiple callbacks into callback queues, invoke callback queues, and relay the fame or failure state of any synchronous or asynchronous function. In jquery 3.0.0 alpha, the objectsjQuery.Deferred are amended to be compatible with Promises/A+ and ES2015 Promises. Hence, there was major development made to a.then() method.

    Better Handling of Error Cases

    This version of jQuery has better care of error cases – incorrect requests which have been ignored till now, throw up errors.

    For example Consider,offset which gets the current relationship to the first element, in the set of matched elements, relative to the document. If you were tricky to find out the offset for a window with prior versions of jQuery, you’d get the result as instead{top: 0, left: 0} of an error being hurled since the offset for a window does not build sense. With the 3.0 alpha version, it will now throw up an error.

    Another example: $("#") now throws an error fairly than returning a 0-length collection.

    Massive Speedups for Custom Selectors Like: visible

    There has been massive performance change made when selectors like visible are used in an archive multiple times. Internally, this is done by caching – so the first time the selector is used, the result is the same. But, each call after that gives conclusions way faster, since caching comes into play. Timmy Willison from jQuery reported that it points to about 17x improvement for the selector:visible!

    Where to Download the Latest Version

    There are two releases:

    1. You can get the latest version directly from https://code.jquery.com/jquery-3.0.0-beta1.js
    2. The minified version is available from https://code.jquery.com/jquery-3.0.0-beta1.min.js

    It’s also available on npm:

    npm install [email protected]3.0.0-beta1

    With Microsoft hailing support for IE8, IE9 and IE10, jQuery has dropped guide for IE8 in jQuery 3.0. If you need IE6-8 support, you should use the latest 1.12 release.

    Feel free to try out this alpha version and give feedback on https://github.com/jquery/jquery. It’s worth a shot!

    See more:

    Javascript vs jQuery Examples

    jQuery Cheat Sheet – All in one

    Latest Articles

    More Recipes Like This