ollyspa
v2.5.1
Published
A lightweight, easy-to-learn JavaScript framework for building single-page apps with pure HTML, CSS, and JS.
Maintainers
Readme
OLLYSPA v2.5 — Beginner-friendly SPA framework.
What is OLLYSPA?
OLLYSPA is a tiny single-page application framework made with plain HTML, CSS and JavaScript. Think of it as a little helper that:
- Lets you switch pages using the URL hash (like
#homeor#about), - Loads small HTML components on demand,
- Lets your page react to data changes (so the UI updates when the underlying data changes),
- Uses a JSON file for the site's content,
- Remembers light/dark theme in
localStorage.
Project structure (what each file does)
index.html
ollyspa.core.js -> the tiny framework (routing + data binding)
data/content.json -> your site's data (editable JSON)
components/home.html -> home page component
components/about.html -> about page component
assets/css/style.css -> default styles (light/dark)
README.mdHow to use it
- Open
index.htmlin a browser (you can just double-click it). - Click the header links or change the URL hash to
#homeor#aboutto switch pages. - Click the "Toggle theme" button — the site will remember the choice using
localStorage.
How the data works (change content)
Open data/content.json and you'll see simple JSON:
{
"site": { "title": "...", "description": "..." },
"home": { "welcome": "...", "features": [...] },
"about": { "title": "...", "content": "..." }
}Change any text here, save the file, then refresh the page. The components read from data and display what's inside.
Some fields are bound for editing in real-time (for example the home page welcome message). That's done with o-model — typing into that input updates the JSON-backed state in the running app.
How routing works
Routing is hash-based:
- The part after
#in the URL is the route name. Example:site.com/#about→ routeabout. - The framework looks for
components/<route>.htmland inserts that component into the page. - If there's no hash, the framework uses
#home.
So, #contact would map to components/contact.html.
How directives work (o-if, o-for, o-model, o-click)
o-if="expression": Shows the element only if the expression is true.o-for="item in list": Repeats an element for each item inlist(useful for building lists).o-model="data.path": Two-way binding for inputs. Changes in the input updatedata.pathin memory.o-click="doSomething()": Run JavaScript expression when clicked (it runs withstateanddatain scope).
Inside templates you can write {{ data.home.welcome }} to show values.
How to add more pages/components
- Create a new file
components/yourpage.html. - Put HTML there (you can use
{{ ... }}interpolation and theo-directives). - Link to it with
<a href="#yourpage">Your page</a>or type the hash in the URL. - Optionally add new content in
data/content.jsonand reference it from your component.
Tips & limitations
- This is educational and tiny: it does not do virtual DOM diffing or advanced performance tricks.
o-forand expression evaluation are intentionally simple — they work for common beginner patterns.- Keep expressions readable and avoid putting complex logic inside templates — move it to
data/content.jsonor a small helper inollyspa.core.js.
Have fun exploring and learning!
