---
title: "How can JavaScript codes be hidden from old browsers that don't support JavaScript?"  
description: "How can JavaScript codes be hidden from old browsers that don't support JavaScript?"  
author: "Anonymous User"  
published: 2019-08-30  
updated: 2020-09-17  
canonical: https://www.mindstick.com/interview/23565/how-can-javascript-codes-be-hidden-from-old-browsers-that-don-t-support-javascript  
category: "javascript"  
tags: ["jquery", "javascript", "scripting"]  
reading_time: 1 minute  

---

# How can JavaScript codes be hidden from old browsers that don't support JavaScript?

For hiding JavaScript codes from old browsers:

Add "<!--" without the quotes in the code just after the <script> tag.

Add "//-->" without the quotes in the code just before the <script> tag.

Old browsers will now treat this JavaScript code as a long HTML comment. While, a browser that supports JavaScript, will take the "<!--" and "//-->" as one-line comments.

## Answers

### Answer by Anonymous User

For hiding JavaScript codes from old browsers:

Add "<!--" without the quotes in the code just after the <script> tag.

Add "//-->" without the quotes in the code just before the <script> tag.

Old browsers will now treat this JavaScript code as a long HTML comment. While, a browser that supports JavaScript, will take the "<!--" and "//-->" as one-line comments.


---

Original Source: https://www.mindstick.com/interview/23565/how-can-javascript-codes-be-hidden-from-old-browsers-that-don-t-support-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
