0

I have an inline piece of javascript like this:

<html>
  <body
    <script>test1</script>
  </body>
</html>

There is an external js that is executed that appends a script below the inline script and over writes it, any thoughts on how to do that?

<html>
  <body
    <script>test1</script>
    <script>externaltest1</script>
  </body>
</html>
3

1 Answer 1

-1

Confused on the question exactly, do you want to append a script tag into your html?

You can append script tags into your html with the following:

var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
$("#yourElement").append(script);

Note: If you are looking to add external js, you would typically include these between <head> or in your footer like so:

<script type="text/javascript" src="yourExtenalScriptPath.js"></script>

Sign up to request clarification or add additional context in comments.

3 Comments

I think OP said INLINE
@Byzod, the first example does append a script into the HTML, does it not?
Further, any function calls defined in both files would always be executed from the last script available, exactly what OP asked. I kindly ask you to reconsider your down vote.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.