Mention what is the correct way to include JavaScript into your HTML?

The best way is to combine all javascript code into one file called something like all.min.js that is also minimized.
In HTML5 you would do something like:
<script src="js/all.min.js">
script>
As you can see, you do not need the type attribute in HTML5, but you require it in other versions of HTML. The spec clarifies that if the content is other than "text/javascript", then you need to specify the type attribute, in HTML5.
 
Any script that you want to include in your HTML code should be included between these tags:

<script>
.....
</script>

Whether you are using Angular JS, React or Node, the method will be the same.




--------------------------------------------------------------------------------
https://www.netguru.co/services/react-js
 
Back
Top