?
avatar Ruud68
Ruud68
4 Nov 2019

Steps to reproduce the issue

in a content plugin onContentPrepare set scriptoptions via:

  1. $document->addScriptOptions and
  2. $document->addScriptDeclaration

Both are set correctly on the page

now enable cache
what you will see now is that addScriptOptions is only displayed on first page visit (page generated) but on second page visit (page from cache) the options are not on the page.

addScriptDeclaration works both on first page view and on page view from cache.

Expected result

$document->addScriptOptions should be stored in the cache
screen shot 2019-11-04 at 14 05 25

Actual result

$document->addScriptOptions is NOT stored in the cache
screen shot 2019-11-04 at 14 05 40

System information (as much as possible)

Joomla 3.9.12

Additional comments

I ran into this issue after migrating my custom javascript variables in my plugin from addScriptDeclaration to addScriptOptions following this guide: https://docs.joomla.org/J3.x:Adding_JavaScript_and_CSS_to_the_page#Adding_the_Options_to_Your_JavaScript_Code

avatar Ruud68 Ruud68 - open - 4 Nov 2019
avatar joomla-cms-bot joomla-cms-bot - labeled - 4 Nov 2019
avatar SharkyKZ
SharkyKZ - comment - 4 Nov 2019

Please test PR #21007.

avatar SharkyKZ SharkyKZ - change - 4 Nov 2019
Status New Closed
Closed_Date 0000-00-00 00:00:00 2019-11-04 14:20:00
Closed_By SharkyKZ
avatar joomla-cms-bot joomla-cms-bot - change - 4 Nov 2019
Closed_By SharkyKZ joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 4 Nov 2019
avatar joomla-cms-bot
joomla-cms-bot - comment - 4 Nov 2019

Set to "closed" on behalf of @SharkyKZ by The JTracker Application at issues.joomla.org/joomla-cms/26975

avatar Ruud68
Ruud68 - comment - 4 Nov 2019

So if I understand correctly, the addScriptOptions function is broken on Joomla! sites that have caching enabled? Hope we get a second tester soon so this can be put into production.

thanks @SharkyKZ for pointing me to the solution to this issue!

Add a Comment

Login with GitHub to post a comment