html+js有咩compiler可以用?

依個世界上, 有無html+js的compiler存在?

依種compiler, 應該要做到以下幾樣野

1. scan整個website folder入面的每一個html, 將入面有call過的javascript以及相關的js code抽出黎放係該html入面 (就算做唔到, 起碼將include過的js 成個file抽出黎)
2. 如果抽出的js code未min, 就要min一次, 理論上最後成個html只會有一行js
3. 將所有<script src="//xxx.js"></script>全部delete晒
4. delete晒所有html tag之間既空白字元, 全部變晒一行

本帖最後由 q_p 於 2014-9-29 15:03 編輯

why are u doing so? what you asked for is just a reformatting of the code.
there is no compilation for html, it is an interpreted language.

TOP

why are u doing so? what you asked for is just a reformatting of the code.
q_p 發表於 2014-9-29 00:28


因為將所有野放晒喺同一個html到可以減少http request數量, 加快page loading嘅速度,
just a reformatting? 如果你有十幾二十個js file要minify, 無理由浪費時間用人手搞

there is no compilation for html, it is an interpreted language.
q_p 發表於 2014-9-29 00:28


html係無compilation, 但係佢其實唔係想要compilation,
係要build system, 例如gulp.js
可以睇睇: http://www.smashingmagazine.com/2014/06/11/building-with-gulp/

TOP

回覆 3# KoolFreeze

moving all js into html may affect caching efficiency. as html are usually dynamically generated while standalone js are static.

the best practice is to minify + compress  html & js & css
and concatenate all js and css  into a single cache-able js/css file respectively

TOP

回覆  KoolFreeze

moving all js into html may affect caching efficiency. as html are usually dynami ...
icarus-c 發表於 2014-9-29 09:41


He didn't say the html is dynamically generated.
Maybe it is, but i won't make assumption.
Or it might be a SPA where everything is static

TOP

Grunt應該有得min JS,加埋RequireJs/HeadJs唔知會點

TOP

回覆 3# KoolFreeze
呵呵 小弟不才,受教了

TOP

但係網絡傳輸唔係有g-zip咩,真係要搞到 del空格 “inline”哂d js code 甘大鑊?
to me those serve as obfuscating the code more then saving bandwidth :/

TOP

本帖最後由 3ldk 於 2014-9-29 21:17 編輯
He didn't say the html is dynamically generated.
Maybe it is, but i won't make assumption.
Or it m ...
KoolFreeze 發表於 2014-9-29 09:50



SPA就沒有太大必要搵工具搞, 一來SPA少野, 二來一頁睇晒, 用既js plugin唔多的話, 有機會手動都搞得到

講緊既係中間有embed server script既html, 所以依D工具應該要做到skip 中間既server script.

TOP

相關文章