Custom Widget external library inclusion question

Hi All, I have a question about creating widgets. What is the proper way to include external files needed for you widget (e.g. jquery or the google api external URL). I've seen different variations on this. The one I have gotten to work is by using dojo dojo.require("myown.external.script") but I had to modify the script and add dojo.provide("myown.external.script") to that file. Which means I am modifying external scripts which is something I prefer not to do it that way because when I am use external libraries it would mean changing thos. It also did not work for the google script, which ofcourse I can not modify because it is externally hosted. Are there any clear guidelines or tips for me on this? Thanks, Alex
2 answers

Every included script must be changed so that dojo.provide("myown.exernal.script") is in the header. The dojo framework uses that to check dependencies.

Maybe you can use #include to include external scripts.

For the jquery includes see the calendar widget which contains extra conditions to prevent including jquery more than once. The complete custom script (widgets.js) is loaded for every mendix page so that can have impacts on the performance.

Edit: Duc is right, snippet from googlemapsoverview.js.

var googleAPILoad = mxui.dom.script({"src" : '', "id" : 'GoogleLoadScript'});

don't forget uninitialize.


Thanks for the reply. What do you mean with #include?

How would one deal with that when the script is not modifiable for example when it is externally hosted (e.g.