polymer Lazy Loading


  1. Create an HTML file (in this example libraries/turf.html) with the library you want to load:

    <script src="../../bower_components/turf/turf.min.js"></script>
  2. Import and use your library when needed:

    doSomething: function(argument, anotherArgument): {
        // If library has not been loaded, load it
        if(typeof turf == 'undefined') {
            this.importHref(this.resolveUrl('../libraries/turf.js'), function() {
                // Once the library is loaded, recursively call the function
                this.doSomething(argument, anotherArgument);
        // Example usage of a library method
        var point = turf.point([42.123123, -23.83839]);