Since the server and DfW have different layout of where to find the files, you need a loader to iron out the differences between the server and DfW. The server only sees the files in your /static/ folder but the DfW will see the app folder with a /static/ folder inside it. There is also a difference when loading files form the server and form locale storage. When reading information from the server, a async call is done to the server. Then the server has returned the information a function is called by the ajax call. When doing the same in DfW, you instantly get the information back. To be able to use server and DfW the same way we have to simulate the callback way of doing thing in DfW.

The dynloader to use

function dynload(url, callback)
    // Adding the script tag to the head as suggested before
    var head = document.getElementsByTagName('head')[0];
    var elm=null;
    var ext='';
    var pos = url.lastIndexOf(".");
    if (pos>=0){
        ext = url.substr(pos);
        ext = ext.toLowerCase();
    switch (ext){
    case '.js':   
        elm = document.createElement('script');
        elm.type = 'text/javascript';
        elm.async = false;
        elm.src = url;

        // Then bind the event to the callback function.
        // There are several events for cross browser compatibility.
        elm.onreadystatechange = callback;
        elm.onload = callback;
    case '.css':
        elm  = document.createElement('link');
        elm.rel  = 'stylesheet';
        elm.type = 'text/css';
        elm.href = url; = 'all';
    // Fire the loading

The loader supports .js files and .css files for now. It will run the callback function when the file is loaded.

Using the loader

indataease = false;
// Test to see if we are running inside DataEase
if (window.external && window.external.hasPrismConnection){ // We are in DataEase
    fromwhere = "DataEase";
    indataease = true;
} else { // We are not in DataEase
    fromwhere = "The server";

Example of setting up a loader from the server and DfW. As you can see each of the files loaded can have their own callback the gets called when the loading is done. You can also omit the callback if you have nothing to do.

Setting up decommon.js for use

// What to do when we are done loading the wrappers that looks the same for server and DataEase
function loadDone(){
  var dec = new DECommon(indataease); // setting it up and telling it if we are in server or DfW
  var query =;
  if (query.length>0) {
    var params = dec.decodequery(query);
    var url=params.file;
    if (url)
    var elm=$("#dqlcontent");
    var code = elm.val();
  $("#delete").on('click',function(me){ dec.delete(); });
    var elm=$("#dqlcontent");
    var code = elm.val();

Setting up decommon.js and calling functions for setting up the environment. As you can see now the differences between server and DfW are hidden from you. The only thing you have to do is use the object created after the dynamic loading of the libraries from the file structure. The object in this example have got the name "dec" for DataEase Common.