Re: ARIA APG - Vanilla JavaScript

On Thu, Mar 26, 2015 at 7:53 AM, Léonie Watson <lwatson@paciellogroup.com>
wrote:

> Since IE9 the number of cross-browser inconsistencies has reduced
> dramatically
>

Reduced, but new bugs pop up regularly in new browsers. jQuery is
constantly working around new bugs. Don't be fooled by the increased
development pace and quality of browsers today; they're far from immune to
regressions and new bugs.

, and many features of jQuery are now features of JavaScript.
>

True, but many can't be used reliably today or the new features are
actually slower than the jQuery implementation.


> For example, the following things are effectively equivalent:
>
>
>
> // jQuery
>
> var getThings = $('#id .class element');
>
>
>
> and
>
>
>
> // JavaScript
>
> var getThings = document.getQuerySelectorAll('#id .class element');
>
>
You meant `querySelectorAll()`, not `getQuerySelectorAll()`. This specific
example is effectively equivalent (minus the fact that iterating is more
difficult), but things like `:not(complex selector)`, leading combinators,
only matching under the current element (`$(element).find()` vs.
`element.querySelectorAll()`), sorting results, etc. don't work the same
and that trips up developers. The DOM APIs have these nice little surprises
hidden in them.

More examples are available here:
>
> http://youmightnotneedjquery.com/
>

I could probably write an entire dissertation on the things that are lost
in the conversions shown on that site, but they're mostly irrelevant here.

The use of JavaScript libraries is in decline.
>

I'm fairly positive this is incorrect. See below for more information.

jQuery remains the most popular library in use, but with each new version
> numbers are diminishing.
>

If you mean the number of sites using a newer version, that's probably
true. Unlike evergreen browsers, new versions of jQuery must be manually
deployed. That's not always feasible or on the top of developers minds when
working on existing sites. You would never say that use of HTML is
diminishing because there are fewer HTML5 sites than HTML4 sites.


> Of the 50 million sites using jQuery, only 1.5 million use jQuery 1.9.x,
>

That seems like a random version to have picked. I'd encourage you to view
the data on http://w3techs.com/technologies/details/js-jquery/1/all.


> and 250,000 use jQuery 2.x. jQuery 2.x is used on fewer sites than
> MooTools, Script.Aculo.us (last updated in 2010), Prototype, and YUI (no
> longer actively maintained) [2].
>

We don't expect jQuery 2.x to be used on many public facing sites because
of the browser support. It's designed for other uses, such as browser
extensions, use in server side scripting, and select sites that don't need
to worry about old IE versions.

Several notable websites do not use jQuery (including Facebook, Wikipedia,
> YouTube and Yahoo!).
>

This is not an accurate list; at least Wikipedia uses jQuery, possibly
others. Yahoo! obviously uses YUI, though that's no longer an active
project, so who knows what will happen in the future.


> Nearly 34% of websites use no large JavaScript library at all [3].
>

More accurately worded, about 30% of sites on the Internet just do not use
JavaScript. These sites should be excluded from consideration, which leaves
about 3% of sites that use JavaScript not using a "popular" library.

Example JavaScript (vanilla) can be used in any context (whether a
> framework is being used to build an application or not). This means
> examples written in JavaScript can be used by anyone.
>

This is the most important thing to consider. Vanilla JavaScript is
definitely the most reusable. Honestly though, if the examples are for
learning, jQuery will not abstract away any important logic and the API is
so straight-forward that there should be no confusion. If the examples are
for copy/pasting, then I think it's safe to assume that copy/paste
developers are using jQuery anyway, but they're more likely to just use an
existing plugin.

Using vanilla JavaScript will also make it easier for people to learn the
> fundamentals of accessible widget functionality. It might be a little more
> verbose to read/write, but it isn’t abstracted into a library – and there
> is no requirement for anyone to learn a particular library in order to
> understand the examples either.
>

I'm honestly curious if you know of people who have looked at jQuery code
and been confused by the API. The DOM API is much more confusing.

Received on Thursday, 26 March 2015 13:05:25 UTC