If you’re writing Chrome apps, we recommend these Chrome app development best practices, including those specific to Chrome Apps and best practices for large web projects that also apply to Chrome Apps.
Best practices specific to Chrome Apps
Build the capability for internationalization into your app
- Use the
chrome.i18n
API and /_locales
/. - Even if you don’t initially plan to offer more than English, supply the English strings via /_
locales
/ andchrome.i18n
if you want to easily expand later.
Decide in advance if your app needs the ability to run offline
- Once your app is written, it’s not trivial to retool it to run offline.
- Set the flag in the manifest. As of Chrome 35, apps are assumed to be offline-enabled and the
offline_enabled
value defaults totrue
, unlesswebview
permission is requested.
Test on Chrome and Chrome OS
- While it’s easier to develop on Chrome than on Chrome OS, if your app will be used on Chrome OS you need to regularly test on all four Chrome OS channels (Stable, Beta, Dev, and Canary).
Test regularly on a device in each Chrome channel
- Because Chrome releases new features frequently, the development platform can change often. By testing regularly, you find out as soon as possible if one of these changes breaks your app.
- Rotate development across Chrome OS devices on Stable, Beta, Dev, and Canary channels (use the command line flag to change to Canary).
Test in kiosk mode (if applicable)
- Because kiosk mode can render things differently than in normal Chrome OS full-screen mode, test in kiosk mode on a Chrome device.
Create a dev, beta, and production app in the Chrome Web Store
- Create a development version of the app that’s only available to people in a certain group, and create a beta version of the app that’s unlisted. Having these versions lets others test the application quickly and without too much risk.
Identify and understand all available APIs
- Browse the public API documentation on the Chrome developer site, such as Chrome Platform APIs and Network and Hardware APIs.
- Browse the API definitions in the Chrome source code to see which APIs might be available but aren’t yet documented.
- Is it safe to use undocumented APIs? It’s risky because undocumented APIs might change or go away without notice. If you use them, test on the Canary channel so you know right away if there’s an API change.
Best practices for large web projects that apply to Chrome Apps
Build accessibility into your app
- The acid test: Can the application be used only with a keyboard?
- The Chrome Accessibility Developer Tools extension adds an Accessibility Audit to Chrome Dev Tools. This audit identifies accessibility problems for you.
- Common issues that limit the accessibility of your app:
- Not providing
onKeyDown
event handlers - Not setting
TabIndex
- Not providing Aria attributes to HTML elements
- Not providing
Use a JavaScript compiler and do unit testing
- It can be difficult to debug large JavaScript® programs. If you’ll have thousands of lines of JavaScript, you should use a compiler to help detect problems.
- Test units or modules of code to isolate the function you’re testing and locate bugs.
Track app usage with Google Analytics
- See how many people are looking at your app in the Chrome Web Store.
- Track app usage. Examples:
- How many people are taking a certain action inside your app
- How long the app stays open