https://github.com/rla/knockoutjs-load
KnockoutJS example code to show spinner while loading page
https://github.com/rla/knockoutjs-load
knockoutjs spinner
Last synced: 4 months ago
JSON representation
KnockoutJS example code to show spinner while loading page
- Host: GitHub
- URL: https://github.com/rla/knockoutjs-load
- Owner: rla
- License: mit
- Created: 2016-03-17T15:29:59.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-17T19:36:57.000Z (over 10 years ago)
- Last Synced: 2025-12-08T18:53:14.167Z (7 months ago)
- Topics: knockoutjs, spinner
- Language: HTML
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
KnockoutJS example code to show a CSS spinner before loading
rest of the page, scripts and data. This is done without
flickering (showing part of markup that is meant to be used as
KnockoutJS template).
## How it works
Page loading flow:
* Browser loads page up to the spinner
* Browser displays the spinner
* Browser loads rest of page, including scripts
* Part of page used for KnockoutJS template is not shown
* Scripts load some data
* KnockoutJS model is bound
* View is rendered and the spinner is automatically hidden
Spinner is wrapped into conditional KnockoutJS tags. These tags
have no effect until `ko.applyBindings` is called:
```html
```
Once `ko.applyBindings` is called, the conditional tags become active
and the loader spinner element is removed from the page DOM by
KnockoutJS.
Rest of the page is wrapped into element that has CSS property
`display: none` set by a class `hide`. This hides the content until
the class is removed:
```html
Message:
```
The class is automatically removed when bindings are applied by
`ko.applyBindings`. This is achieved through the built-in `css` binding.
CSS spinner code was taken from .
## Demo
Visit .
## License
The MIT License.