Unleash the full power of jQuery in Haxe.

To install, run:

haxelib install jQueryExtern 3.0.0 

See using Haxelib in Haxelib documentation for more information.



This version of jQuery extern requires Haxe 3.3+. Users of Haxe 3.2.0- should checkout jQueryExtern 2.0.4.

jQueryExtern Build Status

jQueryExtern unleash the full power of jQuery in Haxe. Currently supports jQuery version up to 1.12.4 / 3.2.1.

This library, jQueryExtern, is a drop-in replacement of the externs in the standard library (js.jquery.*). It utilizes build macros to provide advanced control over the extern for all the special needs.

jQueryExtern allows us to: use a jQuery version other than the one supported in Haxe std lib (see Version Selection) change how jQuery is referenced in output (see Changing Native Reference) * create jQuery plugin externs (see Plugin System)

Download and Install

Install via haxelib:

haxelib install jQueryExtern

Then add -lib jQueryExtern in our hxml.


Version Selection

By default, jQueryExtern provides API same as the one supported by the std extern. It means that using jQueryExtern will not change the default jQuery version. The default jQuery is 1.6.4 in Haxe 3.2 and earlier. Since Haxe 3.3, the default version is set in compiler define jquery-ver. You may check the value of jquery-ver using haxe.macro.Compiler.getDefine. The version is encoded as an interger. e.g. 1.11.3 is encoded as 11103.

jQueryExtern allows changing the supported jQuery version using js.jquery.Config.setVersion. It can be called in a hxml file like this:

--macro js.jquery.Config.setVersion('1.8.3')

The function will also set jquery-ver to the corresponding integer value automatically.

Changing Native Reference

jQuery in the JS output is referred as $, which is an alise of jQuery. Some JS libs, eg. PrototypeJS also use the $ variable, so we may want to refer jQuery by its original name instead.

To do so, add the following compiler option:

--macro js.jquery.Config.setNative('jQuery')

Under the surface, it changes the metadata on the JQuery classes from @:native("$") to @:native("jQuery").

Plugin System

jQueryExtern introduces the js.jquery.Plugin class to ease the process of writing jQuery plugin extern. It is macro-based, responsible for injecting additional fields to the JQuery extern class.

To write a jQuery plugin extern, create an extern class that implements js.jquery.Plugin, and start writing the members as if writing directly inside the JQuery extern class. e.g.:

package jPlugin;
extern class JQueryPlugIn implements js.jquery.Plugin {
    public function myMethod(arg:Dynamic):js.jquery.JQuery;
    static public function myStaticMethod(arg:Dynamic):Void;

To use it, add the following compiler option:

--macro js.jquery.Config.addPlugin('jPlugin.JQueryPlugIn')


jQueryExtern is released in the public domain. NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.

jQuery's license can be found at http://jquery.org/license.

1 year ago

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github