Thursday, July 15, 2010

Update to the Javascript Grid Editor: 1.0.10 (Now with improved initialization!)

There come a time when every developer finds new, improved ways of doing things.  I'm no exception to this, and when I learn something new, I try to implement it wherever I may find it beneficial.

Today's study is about the use of Javascript to dynamically load and initialize script and CSS from external files:

Originally, the Javascript Grid Editor used an asynchronous method of achieving this for both external Javascript and CSS files.  While this worked, it was terribly slow, as each script file was loaded and processed by IE asynchronously, each reporting back to a shared handler that check the status of all outstanding resources.  Crude, but effective.  What it was not, however, was efficient.

Because of the way I was hacking together CRM controls for the JGE, I required these external sources to load before proceeding to implement the controls.  Most users of the JGE experienced this requirement by way of a load time that was either very long, or didn't work at all!  That said, I had been on the lookout for a better method of synchronously loading these scripts without using the dreaded eval() statement.

Today is the day I found it.  Thanks to a very thorough posting by Stoyan Stefanov, I was able to make both the external Javascript and external CSS files load in a synchronous manner, thereby improving the responsiveness and initialization times of the JGE incredibly.  This marks the resolution of a particularly troubling bug I've dealt with in my own deployment.

If you found that the JGE hadn't worked properly for you in the past, I encourage you to grab the latest release.

[ADDENDUM: I've also included the altered code in the IncludeScript(), IncludeStylesheet(), IncludeExternalScript(), and IncludeExternalStylesheet() functions in the CRM Javascript Library.]