Support » Plugin: Code Snippets » Adding JavaScript snippet but doesn’t work

  • Hi,

    Here is the code I need to add to above the closing tag </head>:

    <script src="https://cdn.gravitec.net/storage/xxx/client.js" async></script>

    However, after adding the code below, nothing works.

    
    add_action( 'wp_head', function () { ?>
    <script>
    
    	/* write your JavaScript code here */
    	<script src="https://cdn.gravitec.net/storage/xxx/client.js" async></script>
    
    </script>
    <?php } );
    • This topic was modified 2 years, 8 months ago by legianganh.
    • This topic was modified 2 years, 8 months ago by legianganh.
    • This topic was modified 2 years, 8 months ago by legianganh.
    • This topic was modified 2 years, 8 months ago by legianganh.
    • This topic was modified 2 years, 8 months ago by legianganh.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Code Snippets

    (@codesnippetspro)

    Hey Legian,

    Sorry for the wait. Our upcoming pro version will have full support for JS. Please hang in there a little longer. If your snippet got you stuck ‘nothing works’ you said, please try these to fic things: https://help.codesnippets.pro/collection/4-emergency-fixes

    Cheers,

    Verdi.

    Plugin Author Shea Bunge

    (@bungeshea)

    Hey @legianganh,

    The problem here is that you are putting a <script> tag inside of an existing <script> tag. Your code should look more like this:

    add_action( 'wp_head', function () { ?>
    
    	<script src="https://cdn.gravitec.net/storage/xxx/client.js" async></script>
    
    <?php } );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding JavaScript snippet but doesn’t work’ is closed to new replies.