Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this line of Google closure look like it looks?

Why does this javascript line looks like this? I mean, why there's an extra + near the end?

'<script type="text/javascript" src="' + src + '"></' + 'script>'

Source: http://code.google.com/p/closure-library/source/browse/trunk/closure/goog/base.js#511

like image 442
Marcin Avatar asked Jan 17 '12 20:01

Marcin


1 Answers

Because if you have "</script>" inside of a <script> tag, the browser will think you have closed your script tag. It's a pretty common way to include the text </script> inside of a string within <script> tags.

like image 102
James Montagne Avatar answered Nov 15 '22 11:11

James Montagne