DEV Community

Cover image for loadmodal.js: Bootstrap 5 Modal Window with Fetch API
jQueryScript
jQueryScript

Posted on

loadmodal.js: Bootstrap 5 Modal Window with Fetch API

Need to load Bootstrap modals with content from your server without writing repetitive HTML? loadmodal.js handles the entire workflow for you.

This vanilla JavaScript plugin creates Bootstrap 5 modals dynamically, fetches content via the Fetch API, and manages the complete lifecycle with promise-based callbacks.

At roughly 3KB with only Bootstrap 5 as a dependency, it eliminates the need for static modal templates in your markup.

Key specs:
• Automatic modal HTML generation
• Promise-based callback chains
• Custom button handlers with conditional closing
• Automatic cleanup on modal close
• Full control over fetch options and Bootstrap modal settings

Perfect for admin dashboards, e-commerce applications, and any project where you need on-demand dialogs without cluttering your initial page load.

👉 Blog Post

👉 GitHub Repo

👉 Live Demo

Top comments (0)