Possible Duplicate:
Include JavaScript file inside JavaScript file?
Is there any way to simply import a JavaScript library into a JavaScript file?
In Python, you can simply do this:
import math
Is there anything similar in JavaScript?
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.
In today’s vanilla javascript, no, you can’t do that.
But in a future version, a similar feature will probably be available. Modules are discussed from a long time. And as a Python programmer, you might be interested by this article too.
Today you may
<script>element to your page (yes, it’s ugly)But…
if you always import the same files, you should consider concatenating them (and minifying them), as the number of requested files is one of the main elements to consider when optimizing the performances of your site.