James Kyle
James Kyle

Reputation: 4178

What's <\/script> for?

<\/script>

This is how it is used:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>

I got this from initializr.

Upvotes: 0

Views: 143

Answers (3)

David Schwartz
David Schwartz

Reputation: 182819

The backslash prevents the browser from seeing a </SCRIPT> tag which would end the Javascript. Javascript will eat it, so the output will be </SCRIPT> as desired.

Upvotes: 5

Arnold
Arnold

Reputation: 2420

It’s simply </script> with the forward slash escaped so it doesn’t get automatically encoded by the document.write() function.

Upvotes: 2

dbrin
dbrin

Reputation: 15673

escape character to insure slash outside of the quoted text is not encoded.

Upvotes: 2

Related Questions