-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
@RevillWeb is it a good idea to remove bower and replace it with cdn links via unpkg or rawgit or even an embedded polyfill? I've already done it for some of my components.
Basic Example:
if(!window.customElements || !HTMLElement.prototype.attachShadow) {
loadScript('https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.2.0/webcomponents-sd-ce.js', loadSomeElement );
} else {
if(!window.customElements.get('some-element')) {
loadSomeElement();
} else {
load();
}
}
function loadScript(url, callback){
const script = document.createElement("script")
script.type = "text/javascript";
if (script.readyState){
script.onreadystatechange = function(){
if (script.readyState === "loaded" || script.readyState === "complete"){
script.onreadystatechange = null;
callback();
}
};
} else {
script.onload = function (){ callback() };
}
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
}
function loadSomeElement() {
loadScript('https://cdn.rawgit.com/Nevraeka/some-element/master/some-element.js', load);
}
function load() {
if (!!!window.customElements.get('my-element')) {
window.customElements.define('my-element',
class MyElement extends HTMLElement {
}
);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels