Google’s Polymer zeroes in on ES6 compatibility, interoperability

Polymer 2.0 promises much improved ECMAScript 6 standards support and interoperability with other libraries and frameworks

Google’s Polymer zeroes in on ES6 compatibility, interoperability
422737 (CC0)

Polymer, Google’s open source JavaScript library for building reusable HTML elements, has graduated to version 2.0, a major revision that improves the data system, interoperability with other web libraries and frameworks, and support for ECMAScript 6 standards. ECMAScript is the official specification underlying JavaScript and implemented in web browsers.

Arriving nearly two years after Polymer 1.0, the 2.0 release complies with HTML custom elements v1, for creating new HTML tags, and shadow DOM v1, for self-contained web components. Developers can now draw on Polymer APIs associated with both specifications. Polymer 2.0 uses standard ECMAScript 6 classes and custom elements v1 methods rather than a Polymer factory method, according to release notes. Developers can mix Polymer features with standard JavaScript, although the factory method is still supported via a compatibility layer. 

“Polymer 2.0 is based on web platform standards that are natively supported on over 1 billion mobile devices,” Google’s Wendy Ginsberg, product manager for Polymer, said at the recent Google I/O conference in Silicon Valley. The upgrade is one-quarter the size of Polymer 1.0, she said. Web components built with version 2.0 are interoperable by default, meaning they can be used in popular JavaScript frameworks.

Improvements to the data system make it easier to debug the propagation of data across elements. Simpler array handling is featured along with batched data changes, which can improve performance and correctness.

Polymer 2.0 removes the need to use Polymer.dom for DOM manipulation, making it easier to use Polymer components with other web development libraries and frameworks. In addition, shady DOM code has been repackaged into a reusable polyfill, instead of being integrated into Polymer.

For migrating from Polymer 1.0, Polymer 2.0 features a backward compatibility layer that allows elements written with the 1.0 API to target the 2.0 API and native browser features. A hybrid pattern allows developers to port elements to a common subset of features in Polymer 1.0 and Polymer 2.0. Those elements can run in applications targeting either version of the library, according to Google. Note that some minor template changes may also be needed for migration.

Polymer 2.0 also ships with an improved polyfill loader that loads only the necessary polyfills for an individual browser, resulting in a reduction in payload. Google's goal behind Polymer is to help developers build Progressive Web Apps, which are focused on providing a more native-like application experience, working with multiple form factors and browsers.

Copyright © 2017 IDG Communications, Inc.