javascript “include” strategies

Duplicate of:

Javascript doesn't have any directive to "include" or "import" another js file. This means that if script1.js uses functions/objects defined in script2.js, then every html page that includes script1.js must include script2.js before it.

This shouldn't be a big problem if you only have 2 js files in like 10 html pages. I mean, it's manageable then!

But say suddenly you change script1.js and improve it by using functions/objects defined in a new file, script3.js The problem is, you can't just tell script1.js to include script3.js, instead, you have to remember every html file that included script1.js and update it to include script3.js as well!

This seems like rather stupid way of organizing code.

Are there recommended strategies or practices to deal with this issue?

Would it be acceptable to have a gigantic js file that holds all the functionality that you use across the website?


Use dynamic includes:

Need Your Help

Polymorphic factory / getInstance() in Java

java design-patterns polymorphism factory

I'm aiming to create a set of objects, each of which has a unique identifier. If an object already exists with that identifier, I want to use the existing object. Otherwise I want to create a new o...

NSTreeController/NSOutlineView loses its selection

objective-c cocoa core-data nsoutlineview nstreecontroller

I'm developing a desktop Cocoa application. In the app I have a view-based NSOutlineView binded to an NSTreeController:

Allowing multiple characters in morse code converter

python dictionary morse-code

I'm making a program that takes input and coverts it to morse code in the form of computer beeps but I can't figure out how to make it so I can put more than one letter in the input without getting...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.