I needed to load up the CKEditor library dynamically as part of a module pattern using jQuery’s promises. I kept getting issues about broken paths to files like the skin and the language files due to the context not being the root server path. Because the software I’m working on is installed internationally and on all sorts of servers with different paths I couldn’t use the CKEditor config.baseHref setting. The fastest way to accomplish this is through a custom load script (instead of $.getScript) like so:
function loadScript(srcURL) { var deferred = new $.Deferred(); var e = document.createElement('script'); e.onload = function () { deferred.resolve(); }; e.src = srcURL; document.getElementsByTagName("head")[0].appendChild(e); return deferred.promise(); }
Then you can just pass loadScript the URL to CKEditor (or another complex library that will do sub-sequent downloads and path references) and it will execute in the global space.
Very helpful, thanks!