Jack
Jack

Reputation: 1

Why loading some css and js file taking too long time?

I have an ASP.NET MVC5 application on IIS Server and the login page is loading too slowly after clearing the history of the browser. As it can be seen on the Network field of Developer Tools, there seems to be a serious problem regarding to loading of page contents i.e. css and js files. So, could you please clarify me how to fix this problem for font-awesome and for the other files? How can I increase the page's and the other content's loading?Please note that I first load css files and then page content and at last javascript files. Any help would be appreciated...

enter image description here

Upvotes: 3

Views: 13599

Answers (3)

dolanator
dolanator

Reputation: 300

The cause of very slow loading of JS scripts and CSS files can be multiple and many answers have covered very well some possible causes.

I have myself run into such an issue, having a minified JS script of about 800KB which was taking 26 seconds to load (!). In my case, the file didn't have the X attribute set on the JS file on the server. Also gzip compression was not enabled on the server. After going through all the configuration steps to make gzip work and change permissions to allow the file to execute, it worked.

Upvotes: 0

Dirty Developer
Dirty Developer

Reputation: 562

It seems your browser speed is low. As you've already used minified version and size is not greater than 25kb,still its taking 15 secs.

Other way is to cache those files in browser and reuse everytime(after first call)

caching JavaScript files

Browser Caching of CSS files

Also, i would suggest the following priority

1.Load JS Many times I've faced Js dependency problems. Make sure to load parent js first, then child. Also, try shuffling the js priority, might help you

2.Css

3.Page content

edit Google font offline Downloading a google font and setting up an offline site that uses it

Upvotes: 1

johnniebenson
johnniebenson

Reputation: 540

You can try bundling and minifying those assets in App_Start\BundleConfig.cs

Upvotes: 1

Related Questions