0

Might already be answered but I couldn't find it easily.

Case 1:

<script type="text/javascript" src='external'>
    'Some script here'
</script>

Case 2:

<script type="text/javascript" src='external'></script>
<script type="text/javascript">
    'Some script here'
</script>

So in case 1, does the src lib get loaded first so you can use it in the internal script block? I tried and apparently, it doesn't work. (What I did was store a variable and it didn't work)

If it is supposed to work, is it any different from case 2?

dtc
  • 1,774
  • 2
  • 21
  • 44
  • 1
    Answered here: http://stackoverflow.com/questions/6528325/what-does-a-script-tag-with-src-and-content-mean – sellmeadog Mar 28 '13 at 20:47

3 Answers3

4

In-page script content is ignored when there's a "src" attribute.

Pointy
  • 405,095
  • 59
  • 585
  • 614
3

Case 1 is incorrect. Case 2 is dependent on if you have synchronous or asynchronous code in your external script.

AlienWebguy
  • 76,997
  • 17
  • 122
  • 145
2

src This attribute specifies the URI of an external script; this can be used as an alternative to embedding a script directly within a document. script elements with an src attribute specified should not have a script embedded within its tags.

https://developer.mozilla.org/en-US/docs/HTML/Element/script

philwills
  • 985
  • 4
  • 8