I do not want to use @Scripts.Render("~/bundles/bootstrap") to download file at client side. rather i want to download all bootstrap js file when page load means i want to do defer loading by javascript
I know below way i can download that bundle by javascript but for that i have to know the exact token.
from where to get token value ?
<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "/Scripts/JQueryBundle?v=vFo0kKa-_2_wGzi6Q0u-IemkcVvXrEdKz7OrQ9g-y_c1";
document.body.appendChild(element);
}
</script>
// Check for browser support of event handling capability
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else
window.onload = downloadJSAtOnload;
i also know when any file code changes then token value also changed. so if i use static token then how that works always.
see the javascript code which download bundled js file on page load and where a static or fixed token used to download bundled js file at client side. so tell me how does it work when any js file code changed in that bundle ?
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
77 Points
150 Posts
How to download minified / bundled js file by javascript on page load?
Oct 15, 2020 06:21 PM|TDP|LINK
This way i have bundled my js files
I do not want to use @Scripts.Render("~/bundles/bootstrap") to download file at client side. rather i want to download all bootstrap js file when page load means i want to do defer loading by javascript
I know below way i can download that bundle by javascript but for that i have to know the exact token. from where to get token value ?
i also know when any file code changes then token value also changed. so if i use static token then how that works always.
see the javascript code which download bundled js file on page load and where a static or fixed token used to download bundled js file at client side. so tell me how does it work when any js file code changed in that bundle ?
please guide me. thanks
Contributor
2970 Points
851 Posts
Re: How to download minified / bundled js file by javascript on page load?
Oct 16, 2020 05:10 AM|YihuiSun|LINK
Hi TDP,
You can write a method to return the script.
I gave a solution in the case you posted earlier, you can refer to it.
Best Regards,
YihuiSun