Get started with instantclick CDN

MIT licensed

Library: InstantClick. Instantly renders above-the-fold content while background loads.

Tags:
  • ajax
  • preload
  • pjax
  • history

Stable version

Copied!

How to start using instantclick CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with instantclick CDN - cdnhub.io</title>
  <script src="https://cdn.cdnhub.io/instantclick/3.1.0/instantclick.min.js" defer></script>
  <script>
    document.addEventListener('DOMContentLoaded', function() {
      InstantClick.init(function() {
        // Initialize InstantClick on all elements with the 'data-instantclick' attribute
        InstantClick.init(document.querySelectorAll('a[data-instantclick]'), {
          prefetch: true,
          threshold: 0,
          onAfterLoad: function(pageLink, response) {
            // Called after the page has been loaded
            console.log('Page: ' + pageLink.href + ' loaded');
          }
        });
      });
    });
  </script>
</head>
<body>
  <a href="/page1" data-instantclick>Page 1</a>
  <a href="/page2" data-instantclick>Page 2</a>
  <a href="/page3" data-instantclick>Page 3</a>
</body>
</html>
Copied!
Copied!

All versions