Get started with history CDN

MIT licensed

History.js is a lightweight library for managing the browser history without page reloads.

Tags:
  • history
  • location

Stable version

Copied!

How to start using history CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with history CDN - cdnhub.io</title>
  <script src="https://cdn.cdnhub.io/history/5.3.0/history.development.js"></script>
</head>
<body>
  <button id="goBack">Go Back</button>
  <button id="goForward">Go Forward</button>
  <script>
    const history = new History();

    history.listen((state, action) => {
      console.log('State changed to:', state.url);
    });

    document.getElementById('goBack').addEventListener('click', () => {
      history.go(-1);
    });

    document.getElementById('goForward').addEventListener('click', () => {
      history.go(1);
    });
  </script>
</body>
</html>
Copied!
Copied!
Copied!

All versions