4

i want to include two libraries (jQuery, Highcharts). I tried to add them as additional-js in the config.json File:

"additional-js" : { 
    "add-script" : [
       { "uri" : "script/jquery-3.1.0.min.js" },
       { "uri" : "script/highcharts.js" } 
    ] 
},

The Problem is, that the sequence of the includes are changed by the build. After the build highcharts.js is the first included one. How can i manage the sequence?

F.F
  • 430
  • 2
  • 13

2 Answers2

4

And here is the direct answer to your question:

I've tested this with a fresh created app and the sequence given in config.json IS preserved.

First you have to place the files of the additional libraries in right path of your app (here called myapp) in

  myapp/source/resource/scripts/jquery.js
  myapp/source/resource/scripts/highcharts.js

Then add the folling entry in the job section of myapp/config.json

  "jobs" :
  {
    "common" : {
      "add-script" : [
           { "uri" : "resource/scripts/jquery.js" },
           { "uri" : "resource/scripts/highcharts.js" }
        ]
    },

And finally add the @asset(scripts/*) compiler hint somewhere in your app code, e.g. in Application.jslike this

/**
 * This is the main application class of your custom application "myapp"
 *
 * @asset(myapp/*)
 * @asset(scripts/*)
 */

This way the app loader loads first jquery.js and then highcharts.jsin both source and build version.

And note that the qooxdoo loader is responsible for loading the additional libraries. You don't have and shouldn't place script tags for the libraries in index.html!

level420
  • 829
  • 5
  • 8
2

I know this is not a direct answer to your question. I've never used scripts via the add-script configuration parameter in config.json.

I've also integrated jquery and highcharts in my qooxdoo app using qx.util.DynamicScriptLoader (see http://www.qooxdoo.org/devel/api/#qx.util.DynamicScriptLoader ), which allows loading external libraries on instance initialization, while strictly preserving the given load sequence. This also has the advantage that the libraries are only loaded on demand if e.g. your code creates a dialog containing the highcharts widget.

level420
  • 829
  • 5
  • 8