#45511Tidying up of code produced by inline JavaScript
Description
In TypoScript, when using jsInline or jsFooterInline, the code that you enter is always enclosed in CDATA tags and contains a comment indicating that it is inline JS(!).
It should be possible to indicate that you don’t want CDATA tags (which are XHTML anyway) and definitely no comments should be inserted by the system.
Basically it should be possible to assign some inline JS code and for that code and that code ONLY to appear and nothing extra.
Reviews 2
History 1316
-
Patrick Broens changed Complexity easy <span data-processor="relativetime" data-value="2013-02-18T09:05:35+00:00" > 02/18/13, 09:05 </span>
-
Mathias Schreiber changed target version Is Regression 0 <span data-processor="relativetime" data-value="2015-01-14T09:25:42+00:00" > 01/14/15, 09:25 </span>
-
Benni Mack changed target version <span data-processor="relativetime" data-value="2015-06-15T17:44:49+00:00" > 06/15/15, 17:44 </span>
-
Riccardo De Contardi commented <span data-processor="relativetime" data-value="2015-07-30T12:59:06+00:00" > 07/30/15, 12:59 </span>
-
Susanne Moog changed target version <span data-processor="relativetime" data-value="2015-08-05T10:27:56+00:00" > 08/05/15, 10:27 </span>
-
Benni Mack changed target version <span data-processor="relativetime" data-value="2015-09-24T19:51:42+00:00" > 09/24/15, 19:51 </span>
-
Marc Horst commented <span data-processor="relativetime" data-value="2016-07-10T17:50:32+00:00" > 07/10/16, 17:50 </span>
I just looked up the correct handling of the behavior with CDATA.
And I am not sure if the current behavior is false.The output is
<script type="text/javascript"> /*<![CDATA[*/ /*TS_inlineJS*/ var pageId = 2; /*]]>*/ </script>
The CDATA tag in a comment is the best compatible version.
But it is not really needed since we have HTML5 and modern browsers.Removing the comment is something else.
Maybe the comment is only usefull in debug mode? -
Benni Mack changed target version <span data-processor="relativetime" data-value="2017-03-28T22:26:37+00:00" > 03/28/17, 22:26 </span>
-
Riccardo De Contardi commented <span data-processor="relativetime" data-value="2018-11-23T23:02:06+00:00" > 11/23/18, 23:02 </span>
That still happens in 9.5.2
Maybe there is still someone that uses an xhtml doctype and wants an xml-alike behavior ; I guess that there are 3 scenarios here
1) Completely remove the
/*<![CDATA[*/and let people usepage.headerDatainstead if they really need it. (*)
2) add it only if an xhtml doctype is used
3) transform this into a property ofpage.jsInline(a boolean)(*) Note: I tried also for the scenario 1 to write something like:
page.jsInline { 10 = COA 10.10=TEXT 10.10.stdWrap.dataWrap = var pageId = {TSFE:id}; 10.wrap = /*<![CDATA[*/ | /*]]>*/ }The only problem here is that the
/*<![CDATA[*/wrap does not go away whenconfig.removeDefaultJS = externalis used :( -
Riccardo De Contardi commented <span data-processor="relativetime" data-value="2023-08-03T21:21:11+00:00" > 08/03/23, 21:21 </span>
The issue is still present on TYPO3 12 and 13; but to see it in action you must set:
config.removeDefaultJS = 1
otherwise, the inline js code will be put in an external file, like when you set
config.removeDefaultJS = external
I cannot say if this behavior is intended
-
Benni Mack commented and changed Sprint Focus On Location Sprint <span data-processor="relativetime" data-value="2024-06-14T20:05:49+00:00" > 06/14/24, 20:05 </span>
We can fix this by making the CDATA part removed when having HTML5.
This is actually easy to implement in TYPO3 v13 – just have a look at “wrapInlineScript” and “wrapInlineStyle” and “createInlineCssTagFromFile”
-
Gerrit Code Review pushed patch set 1 for main to change 89304 status
NewUnder Review <span data-processor="relativetime" data-value="2025-05-05T22:40:50+00:00" > 05/05/25, 22:40 </span> -
Gerrit Code Review pushed patch set 2 for main to change 89304 <span data-processor="relativetime" data-value="2025-05-12T15:24:36+00:00" > 05/12/25, 15:24 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 89364 <span data-processor="relativetime" data-value="2025-05-12T18:36:56+00:00" > 05/12/25, 18:36 </span>
-
Benni Mack commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2025-05-12T18:40:07+00:00" > 05/12/25, 18:40 </span>Applied in changeset commit:578a18c3840915bdd70ad645297b98592aefe5f7.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-08-12T14:37:04+00:00" > 08/12/25, 14:37 </span>
It does not happen when
config.removeDefaultJS = external