Ok, so I used a javascript script in my page by referencing the external file and it worked. I did the exact same thing with another file and it wasn't loading! After scratching my head bald I've decided to switch the places of the two tags and voila! the script that worked would not load! The one that did not work previously was purring nicely.

My calls looked like this:
<script type="text/javascript" src='script1.js'/>
<script type="text/javascript" src='script2.js'/>


After scratching my skull a little more (blood was dripping already) I realized that the script tags are atomic tags, they should have no ending tag. Why would they, the content is specified in the src attribute. But on the DOM page for the script element there is an obscure line saying: Start tag: required, End tag: required. I switched to <script></script> format and it worked.

Oh, you are wondering why the first script worked? Because somehow an atomic script tag is erroneous, but it doesn't return any error. Instead it is treated like a mistyped start tag and the atomic portion of it is ignored. The second script would not load since the browser expected a script end tag. Maybe he even interpreted the second tag as an end tag for all I know.

Comments

Anonymous

Anonymous said... Beware xslt, you need to do something like this - substitute angle brackets for parentheses: (xsl:text disable-output-escaping=&quot;yes&quot;)(![CDATA[(script type=&quot;application/javascript&quot; src=&quot;myfile.js&quot;)(/script)]])(/xsl:text) Thanks this saved my life..i was going bonkers Siderite ...see xslt has to do with it as it causes on one script to load..so I ended up here and that post saved me hours of work..

Anonymous

Ati

i should have found your blog a week ago.. many many thanks for this piece of information!

Ati

Anonymous

Wow, this was causing us a huge headache loading javascript in a webview in our mobile app. Leaving off the end tag worked on Android Gingerbread and iOS 4, but died quietly on Android Honeycomb and iOS 5. Thanks so much!

Anonymous

Anonymous

Beware xslt, you need to do something like this - substitute angle brackets for parentheses: (xsl:text disable-output-escaping=&quot;yes&quot;)(![CDATA[(script type=&quot;application/javascript&quot; src=&quot;myfile.js&quot;)(/script)]])(/xsl:text)

Anonymous

petergun

I&#39;ve pulled the rest of my hair out, before I found your post. It was very helpful. Thanks a lot!

petergun

Anonymous

I have been bleeding profusely for a number of hours before you figured out what was going on for me. Thank you very very much.

Anonymous

Post a comment