Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Coffeescript in client side too?

Tags:

coffeescript

Is there any way to use CoffeeScript in client side?

like image 464
Mohsen Avatar asked Jul 23 '11 07:07

Mohsen


1 Answers

There are two ways:

  1. Compile the CoffeeScript to JavaScript and deploy it as you would any JavaScript file, or
  2. Use coffee-script.js, which allows you to put <script type="text/coffeescript> tags in your page.

The latter isn't recommended for production use, but it's nice for development. Or for usage in online editors like these:

<script crossorigin src="https://coffeescript.org/v2/browser-compiler-legacy/coffeescript.js"></script>

<script type="text/coffeescript">
console.log 'Hello World!'
</script>

See the related question: Is there a way to send CoffeeScript to the client's browser and have it compiled to JavaScript *there*?

like image 160
Trevor Burnham Avatar answered Oct 11 '22 05:10

Trevor Burnham