简体   繁体   中英

References Asp.net JS files

I have a notepad filled with references to over 1k.js files. I would like for my page to check this file and add each as a reference eg:

<script type="text/javascript" src="####.js"></script>

any idea or examples on this. Thanks

Not a direct answer to your question, maybe, but if you reference that many files maybe you should look at the Google closure compiler, or the Dojo build system, or search for javascript minifiers?

In addition to your page loading faster, you won't have to generate all those links.

Also not a direct answer, however you could simply create a control which is entered into your asp.net masterpage in the header and geneates your script tags.

However by itself that's going to cause serious performance problems with your website having references to so many javascript files.

I would serioulsy recommend that you look into using the AjaxToolkit (or other frameworks) to merge and minify all of your separate JS files into 1 file that gets generated dynamically.

The example I have below is for both CSS and JS which does minification and compression on the fly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM