Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

cross domain

sola
2008-12-27
2013-04-29
  • sola
    sola
    2008-12-27

    Why dont create <script> element dynamically?

    ...........blocking=1;
    var Head = document.getElementsByTagName('HEAD').item(0);
    var Script= document.createElement("script");
    Script.type = "text/javascript";
    Script.src="lib.js";
    Head.appendChild( Script);

    lib.js
    .........
    ...........blocking=0;
    ......process();
    ........

     
    • As I recall, when I added the dynamic loading of components, this mechanism didn't work in all the browsers I had targeted at the time (it does in modern versions of them, but didn't in earlier ones).  A second reason is the asynchronous nature of the loads, which you allude to with your blocking=1...blocking=0 variable.  Timing issues are pretty critical to jsMath, and subtle timing problems have cropped up in the past.  Because the remote-loading functions were a feature that was added after jsMath was already in use, I wanted to make updates backward compatible without requiring changes in the HTML pages that already worked, which made such issues even more challenging.  Finally, this method requires special coding of the lib.js files to include the necessary handshaking, which I wanted to avoid.

      I have learned a lot working on jsMath, and would certainly do some things differently now in hindsight, and the technology has advanced over that time as well.  The external-file loading is one of the things I'd do differently if I were writing jsMath today, but it would be difficult to change that now while maintaining compatibility with existing jsMath installations.

      Thanks for the suggestion, though.

      Davide