tag-manager icon indicating copy to clipboard operation
tag-manager copied to clipboard

The output is difference from input (Custom HTML tag)

Open patricktobias86 opened this issue 3 years ago • 5 comments

I created a tag using the Custom HTML tag, I entered this code as you read it:

<script src="https://cdn.jsdelivr.net/gh/dixonandmoe/rellax@master/rellax.min.js"></script>
<script>
  var rellax = new Rellax('.rellax');
</script>

The output is different, the two scripts have change order and that means the script wont work:

<script> var rellax = new Rellax('.rellax'); </script>
<script src="https://cdn.jsdelivr.net/gh/dixonandmoe/rellax@master/rellax.min.js"></script>

patricktobias86 avatar Mar 30 '22 21:03 patricktobias86

@patrickdanielsson I tried replicating the issue, can you confirm if the position you have selected is "Body Start" ? Also can you try changing the position to "Body End" and check if it works ?

AltamashShaikh avatar Mar 31 '22 04:03 AltamashShaikh

@patrickdanielsson we added a fix for the ordering issue via #467 This however throws error while executing this line <script> var rellax = new Rellax('.rellax'); </script>

Simple workaround is to update the above code to below code

<script src="https://cdn.jsdelivr.net/gh/dixonandmoe/rellax@master/rellax.min.js" onload="__rellaxAfterLoad()"></script>
<script>
  var rellax;
  function __rellaxAfterLoad() {
      rellax = new Rellax('.rellax')
  }
</script>

Keeping this issue open till we find an actual fix for <script> var rellax = new Rellax('.rellax'); </script>

AltamashShaikh avatar Apr 08 '22 06:04 AltamashShaikh

@patrickdanielsson Note: This changes would go live with Matomo 4.10 which is scheduled to be released by early next month i.e May 2022

AltamashShaikh avatar Apr 08 '22 06:04 AltamashShaikh

@AltamashShaikh could you maybe leave a bit more information about the remaining error and what you know about etc? Just so someone else wouldn't start from scratch and it'll also help prioritising the issue.

If we're not planning to fix this issue anytime soon, it may be worth documenting the issue and the workaround quickly as it's unexpected and CustomHTML tag is probably one of the most used tag.

tsteur avatar Apr 10 '22 20:04 tsteur

For anyone working in future The original issue states that the output of CustomHTML was diiferent

Example

<script src="https://cdn.jsdelivr.net/gh/dixonandmoe/rellax@master/rellax.min.js"></script>
<script>
  var rellax = new Rellax('.rellax');
</script>

Output on page

<script> var rellax = new Rellax('.rellax'); </script>
<script src="https://cdn.jsdelivr.net/gh/dixonandmoe/rellax@master/rellax.min.js"></script>

On further checking it was found that the issue exist when the Position selected is BodyStart.

After applying #467 the Output on page

<script src="https://cdn.jsdelivr.net/gh/dixonandmoe/rellax@master/rellax.min.js"></script>
<script> var rellax = new Rellax('.rellax'); </script>

However, It was noticed that there exist one more error of JavaScript Uncaught ReferenceError: Rellax is not defined, evn though the ordering is correct variable rellax is being evaluated even before the load of rellax.min.js. This issue is not fixed with #467 and needs work.

Alternatively anyone facing the above issue can use this workaround for now, here we evaluate variable rellax only after script is fully loaded via onload attribute on rellax.min.js script tag.

<script src="https://cdn.jsdelivr.net/gh/dixonandmoe/rellax@master/rellax.min.js" onload="__rellaxAfterLoad()"></script>
<script>
  var rellax;
  function __rellaxAfterLoad() {
      rellax = new Rellax('.rellax')
  }
</script>

AltamashShaikh avatar Apr 11 '22 01:04 AltamashShaikh