Forum Moderators: open
I'm putting a lot of JS in an external file and calling it like this:
<script language="javascript" src="js/external.js">
</script>
So, firstly: Is that the correct way to do it?
Secondly, I need to call some JS from another site. Can I do that from within my external JS? And of course, how do I do it?
In the code I'm working on it's just another <script src=> jobbie, I need to be able to do that from the external JS...
Many thanks...
Nick
You can include other JavaScript from other sites by giving the full address ie. [?.com...]
Call from external? You mean as a library? You can include both, i.e. include the external first (as a function library), then include the internal ones that call the functions in the external.
The recommended attribute is type="text/javascript". If you want deep backward compatibility, you can use them both:
<script src="file.js" language="JavaScript" type="text/javascript"></script>