diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index a27cdadfef..5cbefbb5ed 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -17,6 +17,12 @@ */ var singleFile = (typeof OpenLayers == "object" && OpenLayers.singleFile); + /** + * Cache for the script location returned from + * OpenLayers._getScriptLocation + */ + var scriptLocation; + /** * Namespace: OpenLayers * The OpenLayers object provides a namespace for all things OpenLayers @@ -37,7 +43,10 @@ * {String} Path to this script */ _getScriptLocation: function () { - var scriptLocation = ""; + if(scriptLocation) { + return scriptLocation; + } + scriptLocation = ""; var isOL = new RegExp("(^|(.*?\\/))(" + OpenLayers._scriptName + ")(\\?|$)"); var scripts = document.getElementsByTagName('script');