Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
516 views
in Q2A Core by

This creates a burden on page load, which is not present in Q2A 1.8.3.

<script>
var qa_root = '..\/';
var qa_request = '1\/test-the-first-review-site';
var qa_wysiwyg_editor_config = {
    filebrowserUploadMethod: 'form',
    defaultLanguage: 'en',
    language: 'vi-VN'
};
var qa_optids_1 = ["a_notify"];
function qa_display_rule_1(first) {
    var opts = {};
    for (var i = 0; i < qa_optids_1.length; i++) {
        var e = document.getElementById(qa_optids_1[i]);
        opts[qa_optids_1[i]] = e && (e.checked || (e.options && e.options[e.selectedIndex].value));
    }
    qa_display_rule_show('a_email_display', (opts.a_notify), first);
    qa_display_rule_show('a_email_shown', (opts.a_notify), first);
    qa_display_rule_show('a_email_hidden', (!opts.a_notify), first);
}
var qa_optids_2 = ["c2_notify"];
function qa_display_rule_2(first) {
    var opts = {};
    for (var i = 0; i < qa_optids_2.length; i++) {
        var e = document.getElementById(qa_optids_2[i]);
        opts[qa_optids_2[i]] = e && (e.checked || (e.options && e.options[e.selectedIndex].value));
    }
    qa_display_rule_show('c2_email_display', (opts.c2_notify), first);
    qa_display_rule_show('c2_email_shown', (opts.c2_notify), first);
    qa_display_rule_show('c2_email_hidden', (!opts.c2_notify), first);
}
</script>
<script src="../qa-content/jquery-3.3.1.min.js"></script>
<script src="../qa-content/qa-global.js?1.8.4"></script>
<script src="../qa-plugin/wysiwyg-editor/ckeditor/ckeditor.js?1.8.4"></script>
<script>
$(window).on('load', function() {
    for (var i = 0; i < qa_optids_1.length; i++) {
        $('#'+qa_optids_1[i]).change(function() { qa_display_rule_1(false); });
    }
    qa_display_rule_1(true);
    document.getElementById('anew').qa_load = function() { if (qa_ckeditor_a_content = CKEDITOR.replace('a_content', qa_wysiwyg_editor_config)) { qa_ckeditor_a_content.setData(document.getElementById('a_content_ckeditor_data').value); document.getElementById('a_content_ckeditor_ok').value = 1; } };
    document.getElementById('anew').qa_focus = function() { if (qa_ckeditor_a_content) qa_ckeditor_a_content.focus(); };
    for (var i = 0; i < qa_optids_2.length; i++) {
        $('#'+qa_optids_2[i]).change(function() { qa_display_rule_2(false); });
    }
    qa_display_rule_2(true);
    document.getElementById('c2').qa_focus = function() { document.getElementById('c2_content').focus(); };
});
</script>

by
I found a solution for myself, but not sure if anybody cares.
by
Are you sure it’s not present in v1.8.3? The editor is loaded when you view a question so that it can show at the bottom if there are no answers, or can appear straight away if you click the answer button.
by
I have two q2a installations.

In second installation (with 1.8.4), I have to use qa_is_logged_in() function to make sure the editor is loaded only for logged-in users.

Googlebot is considered as a non-logged user, so I have to make sure the CKeditor script won't load for Googlebot.

Maybe I did not compare all settings options of the two installations.

1 Answer

0 votes
by
The CKEditor Javascript should not be loaded for logged-out users. I don't think there is any difference between 1.8.3 and 1.8.4 in that regard. This site is using 1.8.4 and the JS isn't loaded if you're logged out.

There must be some difference in the settings or theme between your two sites. The only thing I can think of is if you allow anonymous users to post answers, then it will load the editor because any visitor might need it.
...