views:

37

answers:

2

I currently use CKEditor on my website, however not every time users access the page CKEditor is needed. The flow is the following: user enters the page and see all the articles there; if users wants to edit the article he ou she opens editor and does that. Cureently CKEditor is loaded in the hidden div and not used 60% of time. Is there any way to load it on demand when user clicks and get that editor div visible?

My CKEditor uses Jquery connector

Thank you

+1  A: 

It depends on how you want to do it, but without seeing your mark-up I'd suggest trying something like:

$('a.editThis').click( // assuming that someone clicks a link of class-name 'editThis' to edit the page
  function(){
    $('<script src="/path/to/CKEditor.js"></script>').appendTo('head');
    return false;
  }
);

Edited to add a link to a demo, albeit this is a demo of appending CSS. I'd imagine that javascript can be added though, and I'll try that next. Demo at: my site

David Thomas
Thank you for your response, I have done something similar :) works like a charm, thank you for providing examples as well!
Mike
@Mike, always a pleasure, and I'm glad to be of help =)
David Thomas
+1  A: 

For other people that don't use JQuery, they should be aware that CKEditor does include its own lazy loader: http://alfonsoml.blogspot.com/2009/09/delayed-loading-of-ckeditor.html

AlfonsoML
that's true, and I couldn't find way to set the correct basepath for it so I stupidly copied all the contents of ckeditor folder to the current directory
Mike
Can you check if the info in my post is enough to fix that issue? (although you can keep using whatever method you prefer afterwards). If it fails, what info is missing?
AlfonsoML