Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a query regarding an issue. As my application using Partial views and these partial views are loaded by ajax call and each partial view usage javascript and include js file, which eventually calls database to bind the data for that particular view. Now, loading the view is taking more time than expected, as it loads js file and that js file makes another call to server to pull the records. I want my view to be loaded and then js file which makes db call to bind data. something like below -

If(partialview is loaded) load js file , which will make ajax call and db eventually to bind data.

This will at least load the view and user will have something to see instead of waiting for blank background with loader.

Please help me to find the proper solution.

Any help will be appreciated.
Posted

1 solution

If you use too many script files in your page it blocks the rendering of the page.
So you better load your script file asynchronously.

for loading your script file asynchronously you just have to add async in your script tag :

HTML
<script src="yourjsfile.js" async></script>


Hope it helps you.
 
Share this answer
 
v2
Comments
Amod Vardhan 25-May-15 7:11am    
Hello Raje thank you for reply. Yes, I did that but no luck. :(
Raje_ 25-May-15 7:20am    
Why are you putting js file inside partial view? if I were you I wouldn't put JavaScript in the partial view at all. Instead of this i will call it on main page.
Amod Vardhan 27-May-15 8:01am    
Thanks. Yes, now i am trying to load all the js file in main page only and call methods accordingly

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900