Category Archives: Programming

Exploring ES6

Given that most of my work these days is HTML5 based, I figured it was time to start looking into ES6 – A long overdue update to Javascript.

For someone that’s used to working with C++ (and AS3), I like IDEs – every developer does. But JS is an ugly beast. An IDE can’t do things like find a function definition or where a var is used with JS (other than through text search which is rarely accurate since the var name is likely not unique). So ES6 features like modules and classes look great.

To my surprise, modules aren’t yet supported in Chrome or Firefox. You need to use Babel or Traceur. I’ve been using RequireJS for the 30k LOC project at work but I thought I could start considering native support with import/export. No go.

What’s worse is that import isn’t explicitly supported by Babel.  You need to use browserify because Babel will translate imports to CommonJS.  So my gulp script is (once again) starting to look awkward.

Ideally, I want to code in ES6, use a watcher to compile automatically, and debug in Chrome’s dev tools with source maps so that I don’t ever see the fugliness.

I’ll post my results if and when I get something feasible.

JSONP and jQuery

Nice little trick I just found out about the getJSON function in jQuery. If you add an extra “?” to the end of the url, it’ll read it as JSONP.  JSONP simply wraps the server’s response (JSON object) in a function. It’s a way to work around cross domain issues. We can finally use the widget creator anywhere, no just on the artist’s own site.