Load Content
Loads and swaps content in place, with optional pagination.
v0.2.0@magic-spells/load-content
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
| Attribute | Description | Default |
|---|---|---|
| current-page | Current page number (1-based) | 1 |
| has-next-page | Whether more pages are available | false |
| url | Base URL for pagination requests | Current page URL |
| targets | CSS selectors for content containers (comma-separated) | "" |
| append-filter | CSS selector to filter which children get appended | "" |
About, features, usage and options are taken from the package README.