This document discusses architecture decisions for a large JavaScript project. It covers the project's technology stack including using Bower for frontend artifacts, ES6 classes for cleaner code, and RequireJS for asynchronous module loading. It also discusses design principles like separation of concerns, testing as a baseline, and enabling easier reusability of components. Specific Angular directives design topics are covered such as making directives singletons, handling state with $scope, and the compile and link functions.
13. Snapshot
Deployment
• For rapidly moving code where bug fixes and
enhancements are coming fast
• Reduce the amount of framework based
checkout and builds
• Less framework variation to maintain
Always Moving forward
31. Minification safe $inject
using the inline, construction way – messy !!
$inject annotation technique – still not good
Use ng-annotateRequireJS plugin
Require-inject.js
34. Putting It All Together
• Define your Angular components as
ES6 Classes
• Configure RequireJS DI
• Use traceur-compiler to convert to
JavaScript-of-today compiler
• Register your class to module
Register -> type (module ,name ,class)
36. What is TypeScript ?
• Open Source
• Compiles to plain JavaScript on any browser
• Syntactic sugar for JavaScript.
• Syntax is a superset of (ES5) syntax
• Primary goal is to add strict typing to
the language (while aligning with ES6)
43. Expressions are forgiving
Type Attribute
Evaluation
Forgiving Control Flow
Statements
JavaScript evaluated
against the
global window
Throw
ReferenceError
TypeError
Supported
AngularJS Properties
Evaluated
against $scope
Encapsulate
the error
null/undefined
No support
add a Decorating $interpolate
44.
45. Angular rendering
• Page Rendering is slower since browser
needs to do the extra work of DOM
• Compatibility with older browsers is hard
to accomplish
• Search Engines Optimization (SEO)
the biggest challenge
46. Angular rendering
• Page Rendering is slower since browser
needs to do the extra work of DOM
• Compatibility with older browsers is hard
to accomplish
• Search Engines Optimization (SEO)
the biggest challenge
52. Import via webjar
Registers
dropbox zxcvbn globally
as it would in the browser
Run a password through
the globally zxcvbn function
Turn the return value
into a Java POJO
60. • Slow — Anything faster than 50 ms is
imperceptible to humans and thus can
be considered as "instant"
• Limited — You can't really show more
than about 2000 pieces of information to
a human on a single page
dirty-checking is inefficient ?
Humans are
61. Lazy loading experiment
Browser performance basic fact:
• User events / layout / rendering / painting
all happen in turns in a single thread
• When your code runs for too long,
user's interaction is blocked.
62. dirty checking
User event
• For Every scope.$$watchers->function return value check
against previous value
• This is called dirty checking and can be quite slow if there are
lots of objects to compare
63.
64. The browser UI is frozen
Challenge : moving the digest cycle and
dirty checking into separate thread.
66. Use Cases
• Prefetching and/or caching data for later use
• Code syntax highlighting
• Real-time text formatting (Spell checker)
• Analyzing video or audio data
• Background I/O or polling of web-services
• Process large arrays or humungous
JSON responses