Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
805 views
in Plugins by
closed by
I try to save a lot of Gigabyte of unnecessary editor loading. Reason: With q2a 1.7.1 and all versions below the editor module gets loaded for anonymous visitors if you allow them to answer.

Here ist the old core hack: http://www.question2answer.org/qa/27681/how-to-load-ckeditor-only-if-clicked-button-answer-or-comment

It still cannot be done with the advanced theme (at least I could not find out how). So I did the hack in 1.7.1 again.

But now I need to know how to prevent the loading of the editor.

 

PS: It feels really unclean to work like that, but i see no other way currently :(
Q2A version: 1.7.
closed with the note: success
by
I'm sure it would be possible for an editor plugin to only make the editor load when it becomes visible. In other words creating your own version of the ckeditor plugin.
by
Hi Scott, I am using the sceditor plugin.

I think it would make sense to implement this behaviour in the core, so that it is valid for each editor.

As I said, it saves several GBytes per month (!) ...
by
edited by
I *revise* my statement, it could be solved by a one-liner in the sceditor plugin:

if(qa_opt('q2apro_sceditor_enabled') && ($this->template=='ask' || $this->template=='question') {

became

            if(qa_opt('q2apro_sceditor_enabled') && ($this->template=='ask' || $this->template=='question') && (qa_is_logged_in() || qa_get_state() || $this->template=='ask')) {

and it is done!

Thanks a lot, Scott (!)

----

Update Jan. 2016:

            if(qa_opt('q2apro_sceditor_enabled') && ($this->template=='ask' || $this->template=='question')
                && (qa_is_logged_in() || qa_get_state() || $this->template=='ask') || $_SERVER['REQUEST_METHOD'] === 'POST')
            {

makes sure that the editor will even load for wrong captchas.
...