Is it possible to load the functions from separate Javascript files dynamically when a window loads, by setting an array and loader function?
Is it possible to load the functions from separate Javascript files dynamically when a
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easiest way is to simply add
<script>elements to the DOM dynamically.Note that you can only do this before the
DOMContentReadyevent is fired.BTW event Google Closure Library uses this technique. And as a sidenote, you probably want to concatenate the scripts into a single file so that you save yourself (and your users) HTTP requests and get faster page loads.
What’s cool about this is that the scripts are downloaded and evaluated right after the closing
</script>tag so you don’t have to wait for anything else before you can use them: