Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions guides/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This folder contains various guides to help those working in software developmen

## Contents

- [Browser code](browser_code.md)
- [Choosing packages](choosing_packages.md)
- [Developer workflows](developer_workflows.md)
- [SQL Prompt](sql_prompt.md)
Expand Down
19 changes: 19 additions & 0 deletions guides/browser_code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Browser code

This guidance provides some useful pointers when developing code for the browser.

### General
* Test your code for compatibility with your target browsers using a tool such as
[Browserstack](https://www.browserstack.com).
* Don't pollute the global state. Take steps such as using a build tool to combine related files or,
at a minimum, [write to window.somenamespace.x rather than window.x](https://www.zendesk.com/blog/keep-javascript-libraries-from-colliding/).
* Think about how you will collect information about errors on the client and consider the use of a tool such as
[airbrake-js](https://github.com/airbrake/airbrake-js).

### Security
* Understand and mitigate the risks of XSS and XSI attacks on your service.
See the OWASP [cheat sheets](https://github.com/OWASP/CheatSheetSeries) for an introduction to these issues.
* Protect against XSS attacks by ensuring that you encode inputs to your service on both the client and server.
You should also perform additional validation on incoming parameters where necessary.
Depending on the library you are using you may need to JS encode and HTML encode to do this.
* Validate inputs on the [client and the server](https://stackoverflow.com/questions/15855770/why-do-we-need-both-client-side-and-server-side-validation#15855799).