Issue Bug Closed

#45511Tidying up of code produced by inline JavaScript

Ian Devlin 02/15/13, 14:48 updated 08/12/25, 14:37

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

  1. Riccardo De Contardi commented <span data-processor="relativetime" data-value="2015-07-30T12:59:06+00:00" > 07/30/15, 12:59 </span>

    It does not happen when config.removeDefaultJS = external

  2. 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?

  3. 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 use page.headerData instead if they really need it. (*)
    2) add it only if an xhtml doctype is used
    3) transform this into a property of page.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 when config.removeDefaultJS = external is used :(

  4. 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

  5. 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”

  6. Benni Mack commented and changed status Under Review Resolved done 0 % 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.