Get started with google-closure-library CDN

Apache-2.0 licensed

Modular JS framework: Google Closure Library for complex apps.

Tags:
  • javascript
  • library
  • goog
  • closure

Stable version

Copied!

How to start using google-closure-library CDN


<!-- Include the Google Closure Library CDN -->
<script src="https://cdn.cdnhub.io/google-closure-library/20230802.0.0/base.js" async></script>

<!-- Define your closure module -->
goog.module('example.MyModule');

// Your closure code goes here
goog.provide('example.MyModule.MyClass');

example.MyModule.MyClass = class {
  constructor() {
    this.message = 'Hello, Closure Library!';
  }

  greet() {
    console.log(this.message);
  }
};

// Make the class available outside of the module
goog.exportPath('example.MyModule', {MyClass: example.MyModule.MyClass});

// Instantiate and use the class
goog.require('example.MyModule.MyClass');
new example.MyModule.MyClass().greet();
Copied!
Copied!

All versions