score:2

Accepted answer

Try using curl.js's legacy loader. It's great for global scripts, such as highcharts.

var hchartBase = "https://code.highcharts.com/";
var hchartCfg = {
    loader: "curl/loader/legacy",
    exports: "Highcharts"
};
curl.config({
    baseUrl: "",
    paths: {
        "curl": "your/path/to/curl/curl.js",
        "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js",
        "hchart": { location: hchartBase + "highcharts", config: hchartCfg },
        "hchartmore": { location: hchartBase + "highcharts-more", config: hchartCfg },
        "hchartexp": { location: hchartBase + "modules/exporting", config: hchartCfg }
    }
});

Note that I included a path to curl. This is needed for curl to find the legacy loader.

Normally, you wouldn't use the same legacy config for all three libs, but since I couldn't tell if the highcharts-more and exporting libs don't declare any useful globals that curl could export on your behalf, I just used the same config for all three.

More info is here: https://github.com/cujojs/curl/tree/master/src/curl/loader


Related Articles