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

  • Home
  • SEARCH
  • 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 203195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:21:26+00:00 2026-05-11T17:21:26+00:00

The following practice is fairly commonplace in the inline JavaScript I have to work

  • 0

The following practice is fairly commonplace in the inline JavaScript I have to work with:

<script type="text/javascript">
   <!--
       // Code goes here
   //-->
</script>

I know that the point is to prevent browsers that are incompatible with JavaScript from rendering the source, but is this still a best practice today? The vast majority of browsers used today can interpret JavaScript; even modern mobile devices usually don’t have trouble.

As for the ‘why not?’ question: I recently had to spend several hours debugging an issue where someone had left off the ‘//’ in front of a ‘–>’ at the end of a script tag buried deep in some pages, and this was causing mysterious JavaScript errors.

What do you do? Is this still considered a ‘best practice?’

  • 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-05-11T17:21:26+00:00Added an answer on May 11, 2026 at 5:21 pm

    The important thing is that nowadays, whether a particular browser supports JavaScript or not is irrelevant (clearly the great majority do) – it is irrelevant because almost all understand script blocks, which means that they know to ignore the JavaScript even if they can’t interpret it.

    Matt Kruse gives a slightly more detailed explanation on his JavaScript Toolbox site for why specifically not to use HTML comments within script blocks.

    Quoted from that page:


    Don’t Use HTML Comments In Script Blocks

    In the ancient days of javascript (1995), some browsers like Netscape 1.0 didn’t have any support or knowledge of the script tag. So when javascript was first released, a technique was needed to hide the code from older browsers so they wouldn’t show it as text in the page. The ‘hack’ was to use HTML comments within the script block to hide the code.

    Using HTML Comments In Script Is Bad

    // DON'T do this! Code is just representative on how things were done
    <script language="javascript">
    <!--
       // code here
    //-->
    </script>
    

    No browsers in common use today are ignorant of the <script> tag, so hiding of javascript source is no longer necessary. In fact, it can be considered harmful for the following reasons:

    • Within XHTML documents, the source will actually be hidden from all browsers and rendered useless
    • — is not allowed within HTML comments, so any decrement operations in script are invalid
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 112k
  • Answers 112k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Check out this related question and this one. Honestly, I… May 11, 2026 at 9:50 pm
  • Editorial Team
    Editorial Team added an answer Are you calling CoInitialize? May 11, 2026 at 9:50 pm
  • Editorial Team
    Editorial Team added an answer I'm not sure the standard guarantees that the data in… May 11, 2026 at 9:50 pm

Related Questions

We have a large application mainly written in SQL Server 7.0, where all database
I'm basically trying to teach myself how to code and I want to follow
I need to develop a generic jQuery-based search plugin for the ASP.NET MVC application
So firstly here's my query: ( NOTE:I know SELECT * is bad practice I
The code looks like below: namespace Test { public interface IMyClass { List<IMyClass> GetList();

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.