How js related is valid javascript

Integration with LinkedIn Javascript is done using

<script src="http://platform.linkedin.com/in.js" type="text/javascript">
   api_key: 9XXXXXXX
   authorize: true
</script>

What I don't understand is how is this valid javascript? Why api_key is not quoted.

+5
source share
1 answer

The body of the script tag is srcnever executed. However, a loaded script can access its contents as the contents of any other element. Thus, this is a good place to store metadata associated with a loaded script.

In fact, it was a pleasant place for him before the attributes were introduced data-. Using them would be more appropriate, but the api related is probably older than the data-attributes, or they just wanted to keep it simple.

- .js:

var scripts = document.getElementsByTagName('script');
var thisScriptTag = scripts[scripts.length - 1];

textContent innerText , .

+8

All Articles