I've noticed many sites use this, without closing the tag.
<script type="text/javascript" src="editor.js">
This style is also recommended but is longer:
<script type="text/javascript" src="editor.js"></script>
Can I write it like this? Is it valid or is there a better way?
<script type="text/javascript" src="editor.js" />
You always want to use
<script type="text/javascript" src="editor.js"></script>
Some browsers do not allow self-closing script tags.
For more information, see Why don't self-closing script tags work?