Questions tagged [google-closure-library]

Closure Library is a JavaScript framework used by Google and one of three components to Closure Tools, an open source toolset to aid with developing front-end web applications

Important links:

374 questions
4
votes
1 answer

Google Closure Compiler - Dead code removal based on externs

I'm trying to use the Google Closure Compiler to split my application code based on where it's going to be run (on the server vs the client) via a single variable. In this example, everything that's going to be called on the server is behind an…
4
votes
2 answers

Use of console.time

I'm creating an application with Google Closure Library and its Compiler. To debug values I use console.log(). Compiling this will throw the following exception JSC_UNDEFINED_VARIABLE. variable console is undeclared at .... To solve this error, I…
4
votes
2 answers

How can I make Google's closure library load faster?

I'm writing a simple phone number parser based on [libphonenumber]. Unfortunately, "http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js" takes forever to load, and when I wget the file and just include it as src="base.js", a bunch…
Zack Burt
  • 8,257
  • 10
  • 53
  • 81
4
votes
1 answer

Does Closure Library have an equivalent to jQuery.live?

In jQuery I can use live() to add event listeners, even for elements that don't exist yet: jQuery('a[href*="/item/"]', pageContent).live('click', preLoadAjaxPage); Does Closure Library have an equivalent? goog.events.EventType doesn't have any "DOM…
Amy B
  • 17,874
  • 12
  • 64
  • 83
4
votes
0 answers

require('google-closure-library') in create-react-app causes Uncaught SyntaxError: Identifier 'module' has already been declared

This can be reproduced by 3 simple steps. Create a new Create React App: npx create-react-app myApp Install Google Closure Library: npm install google-closure-library Import closure library into App.js: require('google-closure-library'); Now…
4
votes
1 answer

Google Closure bind / resolve issues with the this keyword

What is the Google Closure's solution for resolving the issues with the this keyword in JavaScript callback functions. It would be so useful in OO style programming. Is there any conventions or style for OOP in Google Closure??? update How can I…
ehsun7b
  • 4,796
  • 14
  • 59
  • 98
4
votes
1 answer

How to fix encryption of sha256 hmac on google closure library?

Multiple Hmac encrypters ouput a different result of google closure library. I've tried multiple Hmac encrypters and they output the same result. However, when using google closure library, both in NodeJS and ClojureScript, it outputs a totally…
4
votes
1 answer

problems creating custom event dispatcher in google closure library

I'm trying to create a custom event dispatcher in google closure js library. I'm basing this code off of the animation class in the fx folder, yet I keep getting this error.. "goog.events is undefined" yet I'm including the events package at the…
prestonparris
  • 237
  • 1
  • 4
  • 15
4
votes
1 answer

How is lastIndexOf() better than indexOf() in this case?

Here's Google's implementation of String.startsWith() taken from Closure Library: goog.string.startsWith = function(str, prefix) { return str.lastIndexOf(prefix, 0) == 0; }; I was wondering why did they choose lastIndexOf over indexOf given the…
resu
  • 944
  • 12
  • 21
4
votes
0 answers

Accessing google-closure-library methods goog.require and goog.provide

I need to use google-closure-library so I installed this package via npm and put piece of code below (from here) in my webpack (version 3.6.0) config file: module: { rules: [ { test:…
Marcie
  • 41
  • 2
4
votes
1 answer

How to use emscripten in conjunction with the closure tools

For optimal performance I'd like to use emscripten in conjunction with the closure tools but poorly I can't call the function I've defined in JavaScript from emscripten. Note that I extracted a minimal example from my project do demonstrate what I…
noob
  • 8,982
  • 4
  • 37
  • 65
4
votes
1 answer

When to use typedef in closure?

I have been confused for a long time regarding the following code snippet: /** * Pair of width and height. * @param {string} width * @param {string} height * @constructor * @struct */ var Pair = function(width, height) { /** @type {string}…
4
votes
2 answers

Google Closure Library release management

I have read that Closure Library doesn't have any official releases and that one should download the GitHub head to get the latest release. This isn't very convenient for us. The only way we've found so that all developers use the same version is…
Spiff
  • 2,266
  • 23
  • 36
4
votes
1 answer

SHA512 not the same in CryptoJS and Closure

I have some troubles with a simple crypto-challenge. I want to do following: getting a url-encoded and base64-encoded value do url-decoding do base64-decoding hash with Sha512 When working with CryptoJS, i use following code: var parameter =…
crypton00b
  • 85
  • 1
  • 6
4
votes
2 answers

How do I get Google Closure to call my init function when DOM tree finished

I am looking for something like the $(document).ready function in jQuery, as I work on experimenting with using Closure. So, my question is simple, is there a function I am missing that will allow me to wait until my function is called when the DOM…
James Black
  • 41,583
  • 10
  • 86
  • 166