In my application, we have almost 100+ web pages(html page), and all of the container a script which refer to our internal javascript libary.
For example, all of them load this file:
http://server/application/map.js
However, the map.js have to work with jquery
and openlayers
and something else.
And it is not a good idea to add these dependencies to the 100+ pages directly, because the implemention of the map.js
may change someday.
For example, we use openlayers
now, but we may use google map
some day. If then,we will have to modify the 100+ pages to change from openlaeyrs
to google map
.
So I wonder if I can add the dependencies in the map.js
?
Of course I can add the scripts in the map.js
directly like this:
map.js
((function(){
addScript("jquery");
addScript("openlayers");
function addScript(){
// add a script element to the head of the page
}
})();
But it may cause problems because of the js downloding time.
And alternative ideas?