Skip to main content

Vanilla JS

This is the simplest way to use OVA. Download a single file, include it in your HTML, and you're done — no build tools or configuration required.

Installation

Include OVA directly in your HTML — no download or build step required.

jsDelivr:

<script
src="https://cdn.jsdelivr.net/npm/on-view-animations/dist/ova.bundle.min.js"
data-auto-init
></script>

unpkg:

<script
src="https://unpkg.com/on-view-animations/dist/ova.bundle.min.js"
data-auto-init
></script>

Usage

Add the script tag to your HTML file with the data-auto-init attribute. OVA will initialize itself automatically when the DOM is ready — no JavaScript required on your end.

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My Page</title>
</head>
<body>
<div data-ova="">
<h1>Hello World</h1>
</div>

<!-- Load OVA at the end of the body -->
<script
src="https://cdn.jsdelivr.net/npm/on-view-animations/dist/ova.bundle.min.js"
data-auto-init
></script>
</body>
</html>
tip

Place the <script> tag at the end of <body> to ensure the DOM is fully loaded before OVA runs.

Manual initialization

If you need more control over when OVA initializes — for example, after dynamically injecting content into the DOM — you can omit data-auto-init and call initOVA() manually:

<script src="https://cdn.jsdelivr.net/npm/on-view-animations/dist/ova.bundle.min.js"></script>
<script>
window.initOVA();
</script>
tip

Make sure to call initOVA() only after the DOM is fully loaded. If your script is in the <head>, wrap the call in a DOMContentLoaded listener:

document.addEventListener("DOMContentLoaded", () => window.initOVA());