A complete overhaul of the Knockout.js library and build process.
Making Knockout.js slicker, faster, more maintainable than ever.
- Rewrote all library code in ES6+ supported in all modern browsers
- Use native means for iterations, mappings etc. instead of former helper functions (like ko.utils.arrayForEach)
- Reduced indirections by inlining function bodies via Rollup inline-macros plugin
- Turned former source fragments into ES modules
- Retained most of the original names & structure, so catchup & diffing with original Knockout.js remains possible
- Easy circular-dependency detection through ESM imports/exports
- No more worries about loading order of fragments, no more file concatenation at all
- Internals are now self-contained & namespace-agnostic
- no more
ko.foo.bar
references or assignments internally ko.js
being the only source of truth about what is exposed publicly (including legacy aliases)- override-points like
ko.onError
are setters inko.js
, so we gain full control over what can be overridden
- no more
- Removed historic browser support (IE, earliest Firefox etc)
- Removed jQuery support
- Kept all ~1300 tests working with very few changes:
- Added tests for type checking (
ko.isObservable
etc) inbasicTypeCheckBehaviors.js
- Removed IE/jQuery-related tests
- Added tests for type checking (
- Removed Google Closure Compiler and all code soothing its side-effects (
ko.exportSymbol
) - Using Rollup + Terser plugin for build & minification
- Wrote Rollup plugin
rollup-plugin-inline-macros.js
, allowing to "inline" frequently used helper functions & avoid function calls in hot code paths - Now exporting the Knockout.js library in 3 flavors:
- Minified UMD (
knockout.js
) - Minified ES Module (
knockout.esm.js
) - Non-minified UMD debug version incl. sourcemap (
knockout-debug.js
,knockout-debug.js.map
)
- Minified UMD (
- Removed deprecated
PhantomJS
- Added
ESLint
for code quality checks
- After changing any source file during browser testing (
spec/runner.html
), you now have to run therollup-dev
task before the next test-run:-
npm run rollup-dev
build/output/knockout-latest.debug.js
used byrunner.html
. -
- The debug version now has a sourcemap generated alongside it (
knockout-latest.debug.js.map
), so you can attach your IDE's debugger to e.g.runner.html
and add breakpoints inside the actual source files rather than the generatedknockout-latest.debug.js
.
Knockout is a JavaScript MVVM (a modern variant of MVC) library that makes it easier to create rich, desktop-like user interfaces with JavaScript and HTML. It uses observers to make your UI automatically stay in sync with an underlying data model, along with a powerful and extensible set of declarative bindings to enable productive development.
Totally new to Knockout? The most fun place to start is the online interactive tutorials.
For more details, see
- Documentation on the project's website
- Online examples at http://knockoutjs.com/examples/
You can download released versions of Knockout from the project's website.
For Node.js developers, Knockout is also available from npm - just run npm install knockout
.
If you prefer to build the library yourself:
-
Clone the repo from GitHub
git clone https://github.com/knockout/knockout.git cd knockout
-
Acquire build dependencies.
Make sure you have Node.js installed on your workstation. This is only needed to build Knockout from sources. Knockout itself has no dependency on Node.js once it is built (it works with any server technology or none). Now run:
npm install -g grunt-cli npm install
The first
npm
command sets up the popular Grunt build tool. You might need to run this command withsudo
if you're on Linux or Mac OS X, or in an Administrator command prompt on Windows. The secondnpm
command fetches the remaining build dependencies. -
Run the build tool
grunt
Now you'll find the built files in
build/output/
.
If you have phantomjs installed, then the grunt
script will automatically run the specification suite and report its results.
Or, if you want to run the specs in a browser (e.g., for debugging), simply open spec/runner.html
in your browser.
MIT license - http://www.opensource.org/licenses/mit-license.php