How to use coffeescript in developing web-sites?

后端 未结 2 1319
予麋鹿
予麋鹿 2021-01-11 13:24

How do you use CoffeeScript? It need to be compiled, so - you write code in CoffeScript, compile it, and insert real JavaScript on your site?

Doesn\'t it take a lot

2条回答
  •  隐瞒了意图╮
    2021-01-11 13:33

    The answer is yes, you compile it and include the generated JavaScript on your side.

    If you're using a web framework (rails, django etc) you should take a look at the following list of coffeescript plugins: https://github.com/jashkenas/coffee-script/wiki/Web-framework-plugins. They will compile your coffeescript to javascript when you deploy your app to a server.

    Using the coffee-script plugin with the text/coffeescript tags is another option, gzipped and compressed, its only about 39kB, but that can add up if you include it on pages that get many hits and I don't think is a good idea when you can compile the coffeescript to javascript yourself without needing the plugin.

    There is the middleman plugin which will lets you work with CoffeeScript during development, then compile and minify it for deployment.

提交回复
热议问题