What is the danger in including the same JavaScript library twice?

Depending on the library, including it more than once could have undesired effects.

Think of it like this, if you have a script that binds a click event to a button, and you include that script twice, those actions will be ran twice when the button is clicked.

You could write a simple function that you call to load a script and have it keep track of files that have already been loaded. Or, I’m sure you could probably use a pre-existing JS loader such as LabJS and modify it.

Leave a Comment