The Curious History of JavaScript Comments: Why `<!--` and `-->` Work
2025-03-12
This article unravels the curious history behind the use of `` as comment characters in JavaScript. Initially, to ensure compatibility with older browsers, developers would wrap their JavaScript code within HTML comments inside `` tags. Surprisingly, modern browsers still support this syntax due to historical browser compatibility burdens and the standardization committee's commitment to 'not breaking the web'. The article explains how this syntax works and why `-->` must appear at the beginning of a line.
Development