Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-27019

WSRP JavaScript Re-write Resource Loaded Twice

    Details

    • Branch Version/s:
      6.1.x
    • Backported to Branch:
      Committed

      Description

      When creating a <script> element that links to a JavaScript resource using a WSRP resource URL that specifies that the resource requires re-writing, the resulting script is duplicated twice: once re-written and once not re-written. Example:

      Original script file (http://n5o/producerrewrite/script/wsrprewritescript.js)
      -----------------------------------------------------------------------------
      function wsrp_rewrite_Test()
      {
      window.alert('Test');
      }

      Script tag with WSRP resource URL requiring re-writing
      ------------------------------------------------------
      <script type="text/javascript" src="wsrp_rewrite?wsrp-urlType=resource&wsrp-requiresRewrite=true&wsrp-url=http%3a%2f%2fn5o%2fproducerrewrite%2fscript%2fwsrprewritescript.js/wsrp_rewrite"></script>

      Resulting script
      ----------------
      function WSRP_2cad8968ddb046ce8b63_5b6affc6e23e_Test()
      {
      window.alert('Test');
      }
      function wsrp_rewrite_Test()
      {
      window.alert('Test');
      }

      Current workaround
      ------------------
      1) Place all script inline in the markup
      2) If not using WSRP URLs in the script, rewrite the script on the producer side and set "wsrp-requiresRewrite" to "false" in the WSRP resource URL; place all WSRP URLs in the markup only and reference in script

      Note: Could use closures to minimize namespacing to a single variable/property or even none

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                7 years, 2 weeks, 4 days ago

                Packages

                Version Package
                6.1.2 CE GA3
                6.1.30 EE GA3
                6.2.0 CE M2