16

Is the OpenLayers Js script available in a CDN somewhere - in a minified version?

I don't want to load it from their website, that would be to slow and not nice.

Marc
  • 6,535
  • 9
  • 43
  • 75

5 Answers5

21

You can check http://cdnjs.cloudflare.com/ajax/libs/openlayers/2.11/OpenLayers.js

Damirko
  • 226
  • 2
  • 2
  • 1
    New version (3.3.0) and other libraries finding you can find here: http://cs.cdnjs.com/libraries/ol3 – Honza Mar 10 '15 at 10:22
9

I don't think so. There is no point hosting it on CDN because it's not that widely used library(comparing to jQuery), so chances that it's already cached in users browser when they visit your site are small.

More than that - you should build your own custom version of OpenLayers for production that would only contain features that you need, because whole library itself is huge(~ 1mb). Here's how you do it

igorti
  • 3,718
  • 3
  • 19
  • 29
  • Thanks a lot - that was a great idea. I compressed it to what I really needed and got it down to 136kB with jsmin and even to 107kB with closure - perfect! – Marc Dec 23 '11 at 14:56
  • 3
    +1 for building a custom version. But in general CDN is [still faster](http://blog.stackoverflow.com/2011/05/the-speed-of-light-sucks/) even if user will not have the content cached. A decent CDN will have a worldwide set of servers with fat pipes. The user gets the content *faster* even without cache. But agree custom build is the answer for openlayers. – MarkJ Jan 23 '12 at 13:26
  • +1 I was actually searching for that link you posted – jperelli May 26 '12 at 14:56
  • agreed on using custom build for production on your own site. CDN is super handy for jsfiddles and the like though :) – Ward D.S. Jul 02 '15 at 08:14
2

There are multiple hosted versions of the OpenLayers library.

http://openlayers.org/api/OpenLayers.js

via http://docs.openlayers.org/help/minimize.html

almereyda
  • 76
  • 3
2

This might be better suited as a comment if I had the reputation level to write one, but just wanted to add to @Damirko's answer: there have been some minor OL releases since 2.11, but the parent directory of the most recent stable version is http://cdnjs.com/libraries/openlayers/.

EDITS: 1) At time of writing, have not found a CDN for OpenLayers 3 yet. 2) Per @Kevin's input, the OpenLayers.js file in the CDNJS directory I mentioned is the minified version.

Community
  • 1
  • 1
abettermap
  • 600
  • 7
  • 15
2

I was looking for a openlayers 3 cdn and found this answer, I found it in the openlayers examples and desiced to put here this answer in case others are looking for openlayers 3.5 cdn which is the new version currently:

js

https://cdnjs.cloudflare.com/ajax/libs/ol3/3.5.0/ol.js

css

https://cdnjs.cloudflare.com/ajax/libs/ol3/3.5.0/ol.css


ol 3.6 is out:

js

https://cdnjs.cloudflare.com/ajax/libs/ol3/3.6.0/ol.js

css

https://cdnjs.cloudflare.com/ajax/libs/ol3/3.6.0/ol.css

talsibony
  • 7,378
  • 5
  • 42
  • 41