~/talk

30 Tips for Secure JavaScript

Talkat XtremeJS 2025 · on Tuesday, 2025-12-02· [security, javascript]
slides:none on file

Thirty concrete JavaScript practices and a few extras, with exact do/avoid rules: use encodeURIComponent/decodeURIComponent for URL parts, prefer document.createElement and element.textContent over innerHTML, enable CSP and set cookies HttpOnly, add SRI for CDN scripts, run npm audit or yarn audit plus a security static analyzer and linter, defend against HPP and CSRF with server-side validation and tokens, avoid eval/new Function and passing code strings, freeze prototypes or use Object.create(null), and try tools like DOMPurify and retire.js.

AI-written summary · about

  1. 0:00Secure JavaScript intro
  2. 3:26Why security matters
  3. 6:12Output encoding in frameworks
  4. 6:56Secure development lifecycle
  5. 8:21Cross-site scripting seriously
  6. 10:53XSS prevention recipe
  7. 11:15Avoid inline scripting risks
  8. 12:41Treat input as display data
  9. 14:05Safe URL encoding methods
  10. 16:59URL encoding in CSS/DOM
  11. 17:44Removing superpowers from script tags
  12. 18:49Safe static attributes
  13. 19:53Correct content type headers
  14. 20:34Safe CSS variable placement
  15. 21:20Defend against HTTP pollution
  16. 22:05Sanitize DOM content
  17. 22:26SRI for script integrity
  18. 23:08Minify and bundle securely
  19. 23:30Preventing cross-site request forgery
  20. 24:13Static analysis with linters
  21. 24:33Avoid dangerous functions
  22. 26:19Never use untrusted HTML data
  23. 27:02Stop prototype injection
  24. 28:07Same origin policy
  25. 29:12Server-side input validation
  26. 29:32Prefer private variables
  27. 30:14Free security tools
  28. 30:35Conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.