Skip to content
Embed JavaScript files from the web.
Branch: master
Clone or download
Latest commit 46916ef May 28, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode It compiles, let's ship it! May 28, 2017
haxe_libraries It compiles, let's ship it! May 28, 2017
src/embed It compiles, let's ship it! May 28, 2017
tests It compiles, let's ship it! May 28, 2017
.gitignore
.haxerc It compiles, let's ship it! May 28, 2017
.travis.yml Skip node tests. May 28, 2017
LICENSE Initial commit May 28, 2017
README.md Some documentation [ci skip] May 28, 2017
haxelib.json Release 0.1.0 May 28, 2017
tests.hxml It compiles, let's ship it! May 28, 2017

README.md

embed-js

Embed JavaScript files from the web.

Usage is straightforward:

  • with compiler arguments

    --macro embed.Js.from('http://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js')
  • within class initializers

    @:native('ReactDOM')
    extern class ReactDOM {
      static private function __init__():Void {
        embed.Js.from('http://cdnjs.cloudflare.com/ajax/libs/react/15.5.4/react-dom.js');
      }
      static function render(element:ReactElement, target:js.html.Element):ReactElement;
    }

Remarks

  • the downloaded JavaScript files are cached on the file system, with the SHA1 of the URL acting as key. There's currently no way to purge the cache. Most web servers will allow you to add arbitrary query strings to the URL, which you can use to bypass the cache.
  • HTTPS is currently not supported, because the macro interpreter does not support it
  • this library combines rather well with closure, at least to the degree the JavaScript you are embedding is closure compatible.
You can’t perform that action at this time.