0

I have a lot of external scripts to be used for angularjs and so the intial page load becomes slow. Though I need some scripts only for some views. I'm using ui-router. What is the best way to make the inital page load fast?

3
  • 4
    Minify all javascript files Commented Jan 27, 2015 at 13:56
  • 1
    Is there no other way? Commented Jan 27, 2015 at 13:58
  • 1
    Building a single minified file is usually the best way. Your page load is slow because of aggregated network latency and the browser's parallel download limit. A single file mitigates both. Commented Jan 27, 2015 at 14:09

1 Answer 1

1

In modern Internet the size of your script is not actually matters (if it is not several megabytes). Say your script is 500kb minified and gziped (it is really BIG script), say your bandwidth is 10 mbps so your script will be downloaded about 0.4s. It is about that long as DNS lookup + latency will take too. Script loads ones and then it'll be cached. And if you are using Angular I can assume that you're building SPA, so user wants to see all "inner pages" will loads instantly. There is no actual reason to slow its down. And finally, using lazzy loaded angular modules is a tricky thing. So the best choice is to concatenate and minify all js on server side.

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

1 Comment

Yes I think I have to minimize the scripts and concatenate them. That is what I was doing wrong. Thanks.

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.