Search code examples
javascriptgoogle-chromegoogle-chrome-devtoolsgoogle-closuregoogle-closure-library

Use Closure Library inside Chrome DevTools


I've checked out the Closure library as instructred, but can't find a way to use the library (i.e. goog.require('math') inside the Console just for trying it out and testing purposes.

Thanks in advance.


Solution

  • Once Closure Library's base.js is loaded, you can reference the library in the Chrome Dev Tools console.

    closure-test.html (load base.js)

    <!doctype html>
    <html>
    <head>
      <title>Closure Library Test</title>
      <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"></script>
    </head>
    
    <body>
    <h1>Closure Library Test</h1>
    
    </body>
    </html>
    

    Chrome Dev Tools Console

    > goog.require('goog.math');
    <* undefined
    

    Observing Resources | Frames | (closure-test.html) | Scripts, math.js will be loaded.

    > goog.math.modulo(-1, 8);
    <* 7