HAXE JS 101

Written by - Saumya

05 January 2015

Hope you know what is HAXE, take a moment to go through the official HAXE documentation. We will discuss how and what to consider while working with JS in HAXE. Generally other languages, which compile to JS, actually compile each specific file to a respective JS file. HAXE actually compiles to one single JS file for our application. We can further take the generated JS file and minify it using popular JS minifiers.

The work flow for HAXE to JS is as simple as

  • Writing the normal HAXE application
  • Use the package structure and class as usual
  • Make a .hxml file difining what would be the final JS file
  • Compile with HAXE compiler to produce the JS file
haxe compile.hxml

The .hxml file looks something like

-main ApplicationEntry
-js app.js

Thats all to it. HAXE will take care of the import and package and class of the application. Finally the generted JS file is having everything our application needs. Include the JS file in the required HTML file and we are done.

Here is a sample basic application showing all there is to it.

Happy Coding.