Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:05:25+00:00 2026-06-05T12:05:25+00:00

i see this every once in a while when working on projects where customers

  • 0

i see this every once in a while when working on projects where customers provide code:

<script src="xx" type="xx">//</script>

And i always wondered if that’s in any way a correct syntax.
It doesn’t bother any browser at least. But it messes up the syntax highlighter of my editor very badly as it’s not recognizing the closing tag when commented out.

Another flavour would be:

<script>
  //some code
//</script>

I only know this one for preventing code leak into the page:

<script>
 //<!--
 //some code
 //-->
</script>

And i absolutely don’t know what the other ones want to prevent.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:05:26+00:00Added an answer on June 5, 2026 at 12:05 pm

    It is formally correct syntax to write <script src="xx" type="xx">//</script>, because the HTML document is parsed, treating // just as data, and this data is then discarded, since the element has a src attribute. It would of course conform to JavaScript syntax, too, constituting an empty program, with an empty comment.

    The // serves no useful purpose, though. It is debatable whether a nonempty comment would be useful; the HTML5 drafts suggest that it could, see Inline documentation for external scripts there.

    Using //</script> is formally correct but useless.

    A syntax highlighter that gets messed up with it has a bug (it has not been programmed to parse script elements properly).

    Constructs like the one you mention for “preventing code leak into the page”, with <!-- and --> inside script code, are worse than useless codelore. They are useless, since nobody uses Netscape 1 any more. They are worse than useless, since people make typing mistakes in trying to use them (and since by XHTML rules, the comment-like construct is a comment and may be removed by a browser). Besides, the specific construct you mention would not even do the trick on Netscape 1; it would make the characters “//” appear in page content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see code on StackOverflow every once in a while, asking about some overload
See this code: var jsonString = '{id:714341252076979033,type:FUZZY}'; var jsonParsed = JSON.parse(jsonString); console.log(jsonString, jsonParsed); When
I run into this every once in a while and I never really figured
This question is famous but everyone always says go to see this Notepad Tutorial
Please see this piece of code: #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int i
Im working on this bit of code and I keep getting a segmentation fault.
My activity plays a specific sound effect once every second. The following code works,
see this demo from jquery ui you have to hold down the Ctrl key
See this Image below http://i46.tinypic.com/2pt6jkn.jpg This is report in SSRS as shown when it
See this example! int main( int argc, char ** argv ) { int *ptr

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.