with: JavaScripts most reviled keyword
summary
Claims that the with keyword creates a shared per-module object that prevents third-party scripts from leaking globals into the page scope and breaking minifiers resolve as concrete fixes: code uses the closure compiler plus a build tool plover to rewrite functions and top-level assigns, turning 100000+ lines into 25 modules loaded by script tags. A real bug where bing maps changed true to 3 is traced and this module-with approach runs at scale (IE6 compatible) with no observed breakage.
AI-written summary · about
chapters (8)
- 0:00Start
- 0:41What people are saying about with
- 3:27Collisions with application code
- 4:47Preventing collisions when using modules
- 8:43Using with to share module scope
- 11:07Required transformations for this technique
- 14:12Transforming code with the Closure Compiler
- 19:24Summary
related talks
32mBreak all the rules
01h 04mJavaScript's Most Wanted
35m"The Variable Crimes We Commit Against JavaScript"
33mJavaScript the Grumpy Parts
30m"JavaScript, the Real Bad Parts"
01h 10mThe future of JavaScript modules: JS module blocks and native bundling
32mThe Variable Crimes We Commit Against JavaScript
59mNo Strings Attached: JavaScript without Webpack, Transpilers, or Frameworks
