In my HTML file, I have an inline if
statement:
<script>
if(navigator.userAgent.indexOf("Speed Insights") == -1) {
// insert code here
}
</script>
How do I make it print code with <script>
tags inside it?
What I've tried so far
I tried the following:
if(navigator.userAgent.indexOf("Speed Insights") == -1) {
jQuery('footer').append('<script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">window.dojoRequire(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"x","uuid":"x","lid":"x","uniqueMethods":true}) })</script>');
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<footer></footer>
But it breaks. Likely, I am not escaping it properly...?