Mobile platform strategist Peter-Paul Koch held a JavaScript library poll and has now published the results. As you might expect, jQuery was dominant, but it was also revealed that a whopping 95 per cent of respondents used libraries, and most (75 per cent) considered mobile performance acceptable when using existing libraries. Only half (47 per cent) said they considered micro-libraries a better approach than full-scale libraries like jQuery.
We asked Koch if the dominance of JavaScript libraries could lead to issues, such as devs and designers relying on them and not testing sites without JavaScript. “The problem is not testing, and also not the library size, but the CPU time and energy – and thus battery life – that it takes to initialise the library,” he said, citing Who Killed My Battery: Analyzing Mobile Browser Energy Consumption (PDF). Within, a test is described where Wikipedia pages are loaded with jQuery for accordion functionality, and with a small, custom-built script that does the same. The first case drains the battery much more than the second, because jQuery has to be initialised. “Basically what we're looking at here is that the cost of syntactic sugar is too high on mobile, and that we need a new set of libraries that go light on generic features and just do what they need to be doing so as to avoid a costly initialisation process.”
According to Koch, jQuery has become so dominant because of its age and also its accessibility to novices through documentation and community support. The large user-base has subsequently led to more plug-ins, in turn leading to more users. “But this is a problem,” he argued, “because fewer and fewer people now bother to actually learn JavaScript, which is what we need for the mobile web.” He said existing libraries simply aren’t good enough for mobile: “Even on high-powered devices, current libraries are a drain on the battery, and on low-powered devices we have the additional problem that the CPU is slow and initialising the library takes ages.”