Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there CDN for polymer elements?

I would like to know if there are any CDNs for polymer elements, since you have to always download the elements and It would be more convinient to import it via cdn. Can't find any on google? Also are there any reasons that it does not exists or just because it is so new?

like image 275
gorgi93 Avatar asked Jul 19 '14 18:07

gorgi93


3 Answers

There is now!

I created this GitHub repository specifically for this purpose:

download/polymer-cdn

All GitHub repositories are automatically in CDN through RawGit. So, using that, we can now import Polymer elements using markup like this (for iron-icons in this case):

<link rel="import" 
      href="https://cdn.rawgit.com/download/polymer-cdn/1.0.1/lib/iron-icons/iron-icons.html">

The project structure was set up in such a way that imports from elements that you import (transitive dependencies) resolve correctly.

The readme for the repository has a list of all elements it contains.

Missing something? Let me know and I'll be happy to include it.

Try it

You can try it out right now by hacking on this Codepen:

Polymer-CDN Example.

Or you can run this code snippet:

<base href="https://cdn.rawgit.com/download/polymer-cdn/1.5.0/lib/">
<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="iron-icon/iron-icon.html">
<link rel="import" href="iron-icons/iron-icons.html">
<link rel="import" href="paper-button/paper-button.html">
<link rel="import" href="paper-checkbox/paper-checkbox.html">
<link rel="import" href="paper-tabs/paper-tabs.html">
<link rel="import" href="paper-toggle-button/paper-toggle-button.html">
<style is="custom-style">
  :root {
    --paper-tabs-selection-bar-color: var(--paper-light-blue-900);
    --paper-tab-ink: var(--paper-light-blue-100);
    --paper-tabs: {
      color: white;
      background-color: var(--paper-light-blue-500);
    };
  }
</style>

<div>
  <paper-button raised><iron-icon icon="check"></iron-icon>OK</paper-button>
  <paper-button raised><iron-icon icon="clear"></iron-icon>Cancel</paper-button>
</div>

<p><paper-checkbox>Checkbox</paper-checkbox></p>

<p><paper-toggle-button></paper-toggle-button></p>

<paper-tabs selected="0">
  <paper-tab>TAB 1</paper-tab>
  <paper-tab>TAB 2</paper-tab>
  <paper-tab>TAB 3</paper-tab>
</paper-tabs>
like image 136
Stijn de Witt Avatar answered Nov 15 '22 06:11

Stijn de Witt


You can also access polymer elements directly from polymer-project.org.

Example:

<link rel="import" href="https://www.polymer-project.org/0.5/components/core-ajax/core-ajax.html">
like image 7
CletusW Avatar answered Nov 15 '22 08:11

CletusW


This is an old question, but there is a non-hacky solution now: http://polygit.org/

It uses rawgit behind the curtains but provides a much nicer api.

like image 4
Johannes Reuter Avatar answered Nov 15 '22 08:11

Johannes Reuter