Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I move the scripts to the bottom of html.tpl.php
(I have the line <?php print $scripts; ?>
at the end of <body>
) I'm getting the following JavaScript error on pages with CKEditor:
ReferenceError: Drupal is not defined
As others say in the related issue, moving the line <?php print $scripts; ?>
to the <head>
section fixes the problem.
This looks like a workaround, but not as a bugfix since the recommended practise is moving the scripts down into the page for performance reasons.
Comment | File | Size | Author |
---|---|---|---|
#6 | ckeditor-drupal-is-not-defined-2648232.patch | 40.31 KB | vokiel |
|
Comments
Comment #2
Igor Mancos CreditAttribution: Igor Mancos commented+1 Confirm issue, wait fixed version of the module.
Comment #3
jordisan CreditAttribution: jordisan commentedThe problem is in this file: https://git.drupalcode.org/project/ckeditor/-/blob/7.x-1.x/includes/cked...
If the scripts are loaded at the bottom of the page, then that code runs before the Drupal initialization, which causes the error.
WORKAROUND:
You can put all the code of that file inside this:
That way it won't run until the full page is loaded, including the Drupal JS code.
Comment #4
vokiel@jordisan could you please check if moving line 8 before line 5 https://git.drupalcode.org/project/ckeditor/-/blob/7.x-1.x/includes/cked... fixes the issue in your configuration?
Comment #5
jordisan CreditAttribution: jordisan as a volunteer commented@vokiel , in that case you get this error in line 530:
Uncaught ReferenceError: jQuery is not defined
It's the same problem: neither
Drupal
norjQuery
are defined at that point; the workaround I mentioned at #3 does actually work.Comment #6
vokielCreated patch, although I think you @jordisan have already tested it before :-)
Comment #8
vokielComment #9
vokielComment #10
vokielThis fix breaks editor loaded from the
<head>
section.Reverted in bbd0f7c
Comment #11
vokiel