Why isn't Google's Closure library hosted on their CDN?
Asked Answered
I

2

16

Google hosts a number of JavaScript libraries such as jQuery and dojo on their CDN. For some reason, their own Google Closure library does not seem to be included. Is there a hosted version of the Closure library?

Intricacy answered 7/2, 2010 at 21:16 Comment(0)
C
23

It's not included because Closure is intended to be used with the compiler; a hosted version would need to include the entire library and defeat the purpose of building minified libraries containing only the features you need.

Callipash answered 7/2, 2010 at 21:48 Comment(5)
Thanks; I also discovered groups.google.com/group/closure-library-discuss/msg/… which says pretty much the same as you. Unfortunately this decision makes it somewhat difficult to distribute sample JS code as part of another project, that just happens to use the Google Closure library.Intricacy
"somewhat difficult to distribute sample JS code as part of another project" I can't agree with that, if you organize your code into component, it could be reused across your projects. And the powerful compiler tool makes you get a great compact vertion of js file.Lavinialavinie
Well, they could provide a compiled unit and a symbol map to "resume compilation" using the same symbols.Kinnon
What I mean is, I can't post a small code fragment somewhere which hauls the closure library in via <script src="..."> and have the fragment just work. I can do this with Prototype, jQuery, etc.Intricacy
Michael Bolin provides a simple subset of Closure: blog.bolinfest.com/2009/12/…Flagship
E
9

You can link to their repository:

<script src='https://cdn.rawgit.com/google/closure-library/master/closure/goog/base.js'></script>

good enough for demos or local development. As other answer suggested, production should use compiled code, it is well worth it.

Exhortation answered 27/10, 2011 at 7:30 Comment(1)
Move to https://cdn.rawgit.com/google/closure-library/master/closure/goog/base.jsLamellate

© 2022 - 2024 — McMap. All rights reserved.