Searching Open Sourcery

Type to search Open Sourcery.

Media & Content

Load Content

Loads and swaps content in place, with optional pagination.

v0.2.0@magic-spells/load-content

$ npm i @magic-spells/load-content

GitHubnpm

Usage

<!-- Content container that will receive new items -->
<div id="product-grid">
  <div class="product">Product 1</div>
  <div class="product">Product 2</div>
  <div class="product">Product 3</div>
</div>

<!-- Load more button -->
<load-content
  current-page="1"
  has-next-page="true"
  url="/products"
  targets="#product-grid"
  append-filter=".product">
  Load More Products
</load-content>

About

A lightweight, customizable Web Component for implementing "Load More" pagination functionality. Perfect for progressively loading content without full page refreshes while maintaining accessibility and SEO benefits.

Features

  • No dependencies
  • Lightweight and performant
  • Progressive enhancement approach
  • Automatically fetches and appends content
  • Configurable content selectors
  • Built-in loading state management

Configuration

AttributeDescriptionDefault
current-pageCurrent page number (1-based)1
has-next-pageWhether more pages are availablefalse
urlBase URL for pagination requestsCurrent page URL
targetsCSS selectors for content containers (comma-separated)""
append-filterCSS selector to filter which children get appended""

About, features, usage and options are taken from the package README.