首页 > LESS ( client 方式使用) 会不会影响页面的渲染时间?

LESS ( client 方式使用) 会不会影响页面的渲染时间?

这种方式使用LESS

<link rel="stylesheet/less" type="text/css" href="styles.less">
<script src="less.js" type="text/javascript"></script>

会不会比通常的直接引用css方式需要更长的页面渲染时间?


当然会! 你查看一下页面源文件就能发现 less.js 会在 head 里面插入一个 inline-style
打开 firebug 或者别的 console, 你将会看到

less: parsed http://localhost/app.domain.com/static/style.less successfully.
less: saving http://localhost/app.domain.com/static/style.less to cache.
less: css for http://localhost/app.domain.com/static/style.less generated in 66ms
less: css generated in 71ms

上面这个例子比直接引用 css 文件慢了 71ms
耗时主要在于文件生成, 插入节点其实可以忽略不计

【热门文章】
【热门文章】