javascript syntax with escaping slash -
this question has reply here:
why need escape '/' character in javascript? [duplicate] 4 answersi've noticed sites utilize method backup source if google's hosted jquery fails load. copied too, , curious syntax:
window.jquery || document.write('<script src="/js/jquery.min.js"><\/script>');
as understand it, if jquery false or undefined, write out script load jquery locally.
what i'm unsure of is, point of \
in closing script tag? there escape?
thanks!
you escaping whole </script>
tag itself. because, many of older browsers think script gets ended here:
window.jquery || document.write('<script src="/js/jquery.min.js"></script>'); -----------------------------------------------------------------^
that point becomes end of original <script>
tag!
javascript syntax
No comments:
Post a Comment