I’m managing a WordPress website using jQuery v3.6.0 + jQuery.migrate, it triggers a very weird error every time a SCRIPT code is appended to the page.
For example:
jQuery('body').append('<script>console.log("test")</script>');
The returned error is
Uncaught TypeError: n.head.appendChild(...) is undefined
Anyone has ever faced anything similar? Any hint on how to solve?
2
Answers
Here's the answer solving the problem by NOT using jQuery.
(honestly I still don't understand what jQuery might have on that customer website..!)
Try separating the string
<script>
into unrecognizable by compiler by splitting it to two words.