【发布时间】:2014-08-12 08:01:37
【问题描述】:
我正在尝试创建一些没有 Polymer 的自定义元素,如下面的代码。
demo-element.html
<template id="demo-template">
<style type="text/css">
div {
background-color: #F2CEE5;
padding: 10px;
}
</style>
<div><content></content></div>
</template>
<script type="text/javascript">
(function(){
var proto = Object.create(HTMLElement.prototype, {
createdCallback: {
value: function() {
var t = document.querySelector('#demo-template');
var clone = document.importNode(t.content, true);
this.createShadowRoot().appendChild(clone);
}
}
});
var element = document.registerElement('demo-element', {prototype: proto});
})();
</script>
有什么好的解决方案可以缩小这些 html 组件吗?
顺便说一句,我在NodeJS中总是使用UglifyJS来缩小js文件。
【问题讨论】:
-
对于支持 SPDY 的服务器来说,gzipping 是否足够?
标签: javascript web-component shadow-dom