Hacker News new | ask | show | jobs
by adatavizguy 2253 days ago
What are the best resources to learn how to structure a Chrome Extension? I find the API very difficult to grok.
3 comments

The https://developer.chrome.com/extensions/devguide is easy to parse and the https://developer.chrome.com/extensions/samples are quite useful to kickstart the development of a Chrome extension.
> how to structure a Chrome Extension

In the true spirit of JavaScript, you just structure it however you damn well please. Well, not completely, usually you have a background page, a popup page with associated scripts, an options page, optional content scripts, etc. You can learn from examples but in general they’re just structured in whatever way the author feels like.

> I find the API very difficult to grok.

That’s surprising because most APIs are really simple as long as you’re comfortable with callbacks. Sometimes there’s a bit of trial and error (messaging might be one pain point when you write your first extension), and sometimes details might slightly differ from the docs as certain features are tightened up (usually in the name of security), but I’ve never encountered anything that defies a bit of debugging.

Heres a whole repo of extension examples you can probably work with https://github.com/orbitbot/chrome-extensions-examples