0

I was wondering about this because I am planning to load my JS file containing a lot of functions so I can efficiently call them whenever I needed them.

So I can efficiently not create a redundant function on the other page.

And I am wondering if the uncalled functions will increase the page's loading time.

2 Answers 2

1

Well, if gathering those function into one JS file will help you more than the loading time frustrates you. Well that's good.

Even if the file size gets to 2MB, which will also have tens of thousands of code lines. You will not notice the slight loading difference if you have an average internet speed.

It's safe as long as you are not calling all the functions in every load. That will have a great difference.

Sign up to request clarification or add additional context in comments.

Comments

0

They do add load time but it's not much if we're talking individual functions.

My question is why do you want to add functions you might use?

4 Comments

Or do you mean functions that might get called when a user is using your app?
Thank you for your answer. i would like to make a global js file, so when i am developing and i need to make a common code i will just load that global file that contains a lot of functions and only call the function that i need.
Why not just copy the function in instead of the entire file?
It's best practice to keep your code as clean as possible. This way it's readable, maintainable and avoids unnecessary bloat which slows things down

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.