0

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

4
  • Where is that relative path based? Commented Aug 11, 2011 at 23:27
  • 1
    So, what's the problem? Where are you stuck? Commented Aug 11, 2011 at 23:27
  • 1
    1000 JS files! Easy enough to write a quick app to create the text - but that many JS files on a page is going to affect page load performance (trips to the server). You may want to combine JS files into fewer, larger files. Commented Aug 11, 2011 at 23:28
  • All the references are in a notepad file, How do i reference the notepad. eg: the notepad has the references inside while itself is just a txt Commented Aug 11, 2011 at 23:28

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

5 Comments

the issue is combined together all the files are 600mb is that a problem?
600mb yes that is a massive problem for javascript. Even for separate files that is massive. Although minification will reduce that size significantly, it will still cause problems due to the massive size of the files.
Are you sure it's not 600Kb? Ext-all.js is only 500kb in its minified form. Ideally you want your javascript library to be less than 1mb (< 200kb if possible) in its entirely as clients will need to download that before your page will finish loading.
600MB of javascript code? What on earth are you trying to do?
600MB! You could also try something that downloads needed files on demand, Dojo has a require method that a lot of optimization work has gone into, so it won't download a file more than once, for example. Of course if you need them all anyway this won't help. You can even make what they call Layers, which are groups of related javascript files that upload together when you require one of them. You may need a lot of optimizations like this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.