Can i use external script only with .js extensions? Can't i use it when using the extension as .htm?
3 Answers
You can. What matters is the MIME type with which the script is served (by the server). It should be
application/javascript
or
application/x-javascript
This is used by certain PHP scripts that have the .php extension, but actually serve JavaScript (not that I like this, but it's possible).
Comments
Theoretically the extension is not important, it´s the MIME type the server serves the resource that´s important.
In practice there has existed issues with UAs from vendors (IE) that has been file extension maniacs.
Another issue is if you serve the page from the file-protocol.
So my advice, stick with .js
<script src="top_products.php"></script>