最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why loading some css and js file taking too long time? - Stack Overflow

programmeradmin2浏览0评论

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...

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...

Share Improve this question asked Dec 28, 2016 at 22:24 JackJack 1 1
  • One way is to use minified version of js. And the other one is to load all the js files in cache. – Dirty Developer Commented Dec 28, 2016 at 23:51
Add a ment  | 

3 Answers 3

Reset to default 1

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

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

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 pression 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.

发布评论

评论列表(0)

  1. 暂无评论