﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
13777	Loading ckeditor with $.getScript or webpack fails: Is there a way to load the script on demand, only if it's needed?	pang		"== Goal ==

I'm building a SPA that needs rich text editing for a few formularies.

My goal is to load the heavy ckeditor only if it's required, and save the download and the loading time for the majority of visitors that do not need to edit rich text.

I'm also using webpack, but it's documented elsewhere that ""require('ckeditor')"" and such don't work either.

== Steps to reproduce ==

1.If I want to turn on ckeditor for several textareas, I call:

{{{
ck.basic_editor(['id1', 'id2'])
}}}

where basic_editor is as follows:

{{{
ck.basic_editor = function(ls){
   var load_when_lib_is_ready = function(){
       var i;
       for(i=0;i<ls.length;i){
         if (window.CKEDITOR.instances[ls[i]]==undefined){
             window.CKEDITOR.replace( ls[i] ,
               {
                   customConfig : '../../js/plugins/ckeditor/ckeditor_config.js'
               });
         }
       }
   };
   if(window.CKEDITOR){
       load_when_lib_is_ready();
   }else{
       $.getScript(BASE_URL + 'ckeditor/ckeditor.js', load_when_lib_is_ready);
    }
}

}}}

2. No matter where I place the above code, or the ckeditor script, I get errors like:

Uncaught SyntaxError: Unexpected token <

Uncaught TypeError: Cannot set property 'dir' of undefinedCKEDITOR.lang.load.f @ VM2040:212CKEDITOR.scriptLoader.load.g @ VM2040:214CKEDITOR.scriptLoader.load.l @ VM2040:214CKEDITOR.scriptLoader.load.s @ VM2040:214(anonymous function) @ VM2040:215

3. I've tried other combinations, same result.

== Expected result ==

== Actual result ==

== Other details (browser, OS, CKEditor version, installed plugins) ==
Using webpack, npm, bower, gulp (not much really): any solution that works for the stated goal is fine. I also have other heavy libs that most visitors don't need.

Tested on firefox and chromium, ckeditor 4.5.3, but it also happened with version 3, I don't recall the specific number.

Regards"	Bug	closed	Normal		General	4.5.3	invalid	getScript, on demand, webpack	
