Gathering detailed insights and metrics for @polymer/polymer
Gathering detailed insights and metrics for @polymer/polymer
Gathering detailed insights and metrics for @polymer/polymer
Gathering detailed insights and metrics for @polymer/polymer
npm install @polymer/polymer
99.1
Supply Chain
100
Quality
86.1
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
22,043 Stars
6,886 Commits
2,015 Forks
839 Watching
91 Branches
152 Contributors
Updated on 28 Nov 2024
Minified
Minified + Gzipped
HTML (63.2%)
JavaScript (36.68%)
Shell (0.09%)
CSS (0.03%)
Cumulative downloads
Total Downloads
Last day
-5.9%
22,319
Compared to previous day
Last week
2.8%
127,801
Compared to previous week
Last month
4.1%
550,872
Compared to previous month
Last year
20.4%
5,253,247
Compared to previous year
1
26
ℹ️ Note: This is the current stable version of the Polymer library. At Google I/O 2018 we announced a new Web Component base class,
LitElement
, as a successor to thePolymerElement
base class in this library.If you're starting a new project, we recommend that you consider using LitElement instead.
If you have a project you've built with an earlier version of the Polymer library, we recommend that you migrate to 3.0 for best compatibility with the JavaScript ecosystem. Thanks to the interoperability of Web Components, elements built with Polymer 3.0 and LitElement can be mixed and matched in the same app, so once you have updated your project to Polymer 3.0, you can migrate to LitElement incrementally, one element at a time. See our blog post on the Polymer Project roadmap for more information.
Polymer lets you build encapsulated, reusable Web Components that work just like standard HTML elements, to use in building web applications. Using a Web Component built with Polymer is as simple as importing its definition then using it like any other HTML element:
1<!-- Import a component --> 2<script src="https://unpkg.com/@polymer/paper-checkbox@next/paper-checkbox.js?module" type="module" ></script> 3 4<!-- Use it like any other HTML element --> 5<paper-checkbox>Web Components!</paper-checkbox>
Web Components are now implemented natively on Safari and Chrome (~70% of installed browsers), and run well on Firefox, Edge, and IE11 using polyfills. Read more below.
The easiest way to try out Polymer is to use one of these online tools:
Runs in all supported browsers: StackBlitz, Glitch
Runs in browsers with JavaScript Modules: JSBin, CodePen.
You can also save this HTML file to a local file and run it in any browser that supports JavaScript Modules.
When you're ready to use Polymer in a project, install it via npm. To run the project in the browser, a module-compatible toolchain is required. We recommend installing the Polymer CLI to and using its development server as follows.
Add Polymer to your project:
npm i @polymer/polymer
Create an element by extending PolymerElement and calling customElements.define
with your class (see the examples below).
Install the Polymer CLI:
npm i -g polymer-cli
Run the development server and open a browser pointing to its URL:
polymer serve --npm
Polymer 3.0 is published on npm using JavaScript Modules. This means it can take advantage of the standard native JavaScript module loader available in all current major browsers.
However, since Polymer uses npm conventions to reference dependencies by name, a light transform to rewrite specifiers to URLs is required to run in the browser. The polymer-cli's development server
polymer serve
, as well aspolymer build
(for building an optimized app for deployment) automatically handles this transform.
Tools like webpack and Rollup can also be used to serve and/or bundle Polymer elements.
PolymerElement
.properties
getter that describes the element's public property/attribute API
(these automatically become observed attributes).template
getter that returns an HTMLTemplateElement
describing the element's rendering, including encapsulated styling and any property bindings.1 <script src="node_modules/@webcomponents/webcomponents-loader.js"></script> 2 <script type="module"> 3 import {PolymerElement, html} from '@polymer/polymer'; 4 5 class MyElement extends PolymerElement { 6 static get properties() { return { mood: String }} 7 static get template() { 8 return html` 9 <style> .mood { color: green; } </style> 10 Web Components are <span class="mood">[[mood]]</span>! 11 `; 12 } 13 } 14 15 customElements.define('my-element', MyElement); 16 </script> 17 18 <my-element mood="happy"></my-element>
Web components are an incredibly powerful new set of primitives baked into the web platform, and open up a whole new world of possibility when it comes to componentizing front-end code and easily creating powerful, immersive, app-like experiences on the web.
Polymer is a lightweight library built on top of the web standards-based Web Components APIs, and makes it easier to build your very own custom HTML elements. Creating reusable custom elements - and using elements built by others - can make building complex web applications easier and more efficient.
By being based on the Web Components APIs built in the browser (or polyfilled where needed), elements built with Polymer are:
Among many ways to leverage custom elements, they can be particularly useful for building reusable UI components. Instead of continually re-building a specific navigation bar or button in different frameworks and for different projects, you can define this element once using Polymer, and then reuse it throughout your project or in any future project.
Polymer provides a declarative syntax to easily create your own custom elements, using all standard web technologies - define the structure of the element with HTML, style it with CSS, and add interactions to the element with JavaScript.
Polymer also provides optional two-way data-binding, meaning:
Polymer is designed to be flexible, lightweight, and close to the web platform - the library doesn't invent complex new abstractions and magic, but uses the best features of the web platform in straightforward ways to simply sugar the creation of custom elements.
Polymer 3.0 is now released to stable, and introduces a major change to how Polymer is distributed: from HTML Imports on Bower, to JS modules on npm. Otherwise, the API is almost entirely backward compatible with Polymer 2.0 (the only changes are removing APIs related to HTML Imports like importHref
, and converting Polymer's API to be module-based rather than globals-based).
Migrating to Polymer 3.0 by hand is mostly mechanical:
static get template()
getter on PolymerElement subclasses using the html
tagged template literal function (which parses HTMLTemplateElement
s out of strings in JS) rather than using <template>
elements in a <dom-module>
However, the polymer-modulizer
tool automates the vast majority of this migration work. Please see details on that repo for automated conversion of Polymer 2.0 apps and elements to Polymer 3.0.
👀 Looking for Polymer v2.x? Please see the v2 branch.
👀 Looking for Polymer v1.x? Please see the v1 branch.
The Polymer team loves contributions from the community! Take a look at our contributing guide for more information on how to contribute. Please file issues on the Polymer issue tracker following the issue template and contributing guide issues.
Beyond GitHub, we try to have a variety of different lines of communication available:
The Polymer library uses a BSD-like license that is available here
No vulnerabilities found.
Reason
11 commit(s) out of 30 and 1 issue activity out of 30 found in the last 90 days -- score normalized to 10
Reason
no vulnerabilities detected
Reason
no dangerous workflow patterns detected
Reason
tokens are read-only in GitHub workflows
Reason
license file detected
Details
Reason
all dependencies are pinned
Details
Reason
no binaries found in the repo
Reason
GitHub code reviews found for 23 commits out of the last 30 -- score normalized to 7
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
no badge detected
Reason
security policy file not detected
Reason
no update tool detected
Details
Reason
project is not fuzzed
Score
Last Scanned on 2022-08-15
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More