Perhaps not the right category (bug), but it is making the node edit form real slow. Actually everywhere a WYSIWYG editor is being used.

The situation

The hook which defines the Easychart WYSIWYG editor plugin (plugins/easychart.inc) is loading all existing charts so it can pass that along to the JS (plugins/js/plugin.js). In the JS it uses that information to be able to show a live preview when a chart is being added. It does a callback to the Highcharts website with the chart's configuration options.

The problem

When adding a textarea field, with a WYSIWYG editor attached to it, via Paragraphs, which is loading the form element via a AJAX callback, the response includes all the necessary JS and thus also those settings. If have a little under 300 charts, which makes the response about 200 pages long. Parsing all this takes at least about 3 seconds, if we're lucky.

I guess it's not really a Paragraphs/AJAX problem. I suppose this causes any page page including a WYSIWYG editor to be slow.

The ugly truth

Even if you don't add a chart, this info is being passed, which is obviously overkill. It would be better to have a callback to fetch those options when the chart is actually being added.

The really nasty truth

The plugin does not even need to be enabled for your WYSIWYG text format. Since the hook_wysiwyg_plugin is being called just to define the plugins, it's really not a good place to be adding any large JS. Perhaps there's no other moment to include libraries etc. (like when the plugin is actually used), which may be a flaw in the WYSIWYG API, but if we can avoid adding 200 pages worth of information, we should propabably do that :-).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sneakyvv created an issue. See original summary.

Sneakyvv’s picture

Status: Active » Needs review
FileSize
7.65 KB

Patch attached which adds said callback.

Sneakyvv’s picture

Version: 7.x-2.5 » 7.x-2.x-dev

Patch also applies to dev.

Sneakyvv’s picture

FileSize
8.61 KB

Patch updated. It added arguments $editor and $version to easychart_easychart_plugin() in plugins/easychart.inc, because the PHP doc says it's an implementation of hook_wysiwyg_plugin().

Well it isn't... Adding the arguments caused a PHP notice, since it was being called from _wysiwyg_process_include(), which does not pass those arguments. That's because it's really an implementation of hook_wysiwyg_include_directory(). So updated patch accordingly.

PS: Perhaps a separate patch for the wrong PHP doc might be in place, but well... If this patch gets committed soon, there's no need for it :-)

thomas_rz’s picture

Assigned: Unassigned » Sneakyvv
Sneakyvv’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
FileSize
7.5 KB

The problem still exists in 7.x-3.x but in the wysiwyg submodule. This patch is for that version.

  • Sneakyvv committed 75db1aa on 7.x-3.x
    Issue #2827041 by Sneakyvv: Eliminate existingCharts (Drupal JS setting)
    

  • Sneakyvv committed d42db1c on 7.x-2.x
    Issue #2827041 by Sneakyvv: Eliminate existingCharts (Drupal JS setting)
    
Sneakyvv’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.