Install
官文: https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html
1 | git clone https://github.com/emscripten-core/emsdk.git |
需要 xcode + command line tools, git, cmake, nodejs, python
Hello World ~
1 |
|
1 | emcc a.c |
浏览器运行
1 | emcc a.c -o index.html |
打开浏览器访问 http://127.0.0.1:8080
预加载文件
浏览器内部的文件系统是一个沙盒概念, 无法与外部系统直接交互
1 | emcc a.c -o index.html --preload-file somefile.txt |
js 压缩比
在生成 js 文件的时候, 默认是不压缩的
但是在测试或者上线发布的时候, 为了追求包体大小, 一般传统的前端是要做压缩混淆的
1 | emcc a.c # 不压缩 |
Tips: 这里注意是大写的欧, 不是零或者小写.