Is calling functions in different JavaScript files slowing down JavaScript processing by the browser?
In other words, can I call functions from a file to another one?
Or would it be better to call function in the same file?
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.
It makes no difference at all. Regardless of which script file the code comes from, it gets intepreted into the document’s context, which is the same for all of the script files and inline script on the page.
You can test it with this incredibly sloppy script: http://jsbin.com/uxiye
Somewhat off-topic, but some of the other answerers are absolutely right to point out that while there’s no difference executing the functions, there can be a big difference in script load time… You didn’t ask about page load time, but still, worth pointing out.