Skip to content

Maxim-Mazurok/gapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Un-minified GAPI project

This project aims to make minified GAPI (https://apis.google.com/js/api.js) source code readable and understandable.

Why?

  1. To create accurate type definitions for TypeScript (examples: @types/gapi.client, @types/gapi)
  2. To create better optimized clone that will be distributed via NPM

Current findings

  • api.js only defines one public method: gapi.load
  • gapi.load accepts libraries and callbackOrConfig arguments, as documented, but callbackOrConfig also has undocumented property: config
  • gapi.client methods are defined in the client library that is being loaded by gapi.load

Current approach

  1. Beautify code
  2. Go line-by-line
  3. Make that line more readable and easier to understand
  4. Leave original line commented out for future references
  5. Rename all minified variables (one letter, etc.)
  6. When renaming variables, do that in ALL_CAPS prefixed with __UM__, like gapi.__UM__SOME_UNIX_TIME_NUMBER

Next steps

  1. Try to rewrite this script and make sure that it works
  2. Probably add unit tests to make sure that we have a good understanding of how all parts work
  3. Try adding TypeScript, it may make rewriting easier since we don't have to keep in mind what that variable does/contains

Testing

Performance comparison

Measured by appending api.js script, loading client lib and returning gapi to the main testing script.

Conclusion: Use puppeteer because it's fast and uses Chrome.

About

Un-minified GAPI project

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published