---
title: Boostify - Full Documentation
description: Complete documentation for Boostify JavaScript performance toolkit
version: latest
last_updated: 2026-09-09
url: https://boostifyjs.com/llms-full.txt
---
# Boostify - Complete Documentation
> A JavaScript toolkit for web performance optimization. Load scripts, styles, and media on-demand using smart triggers.
## Quick Links
- Website: https://boostifyjs.com/
- Repository: https://github.com/andresclua/boostify
- NPM: https://www.npmjs.com/package/boostify
- Condensed version: https://boostifyjs.com/llms.txt
- Claude Code skill: https://boostifyjs.com/boostify-skill.md
## Installation
```bash
npm install boostify
```
```javascript
import Boostify from 'boostify';
const bstf = new Boostify({
debug: true,
license: "YOUR-LICENSE-KEY"
});
```
Or via CDN:
```html
```
---
## API Reference
### Content Injection Methods
#### loadScript(options)
Dynamically inject JavaScript files or inline scripts.
```javascript
await bstf.loadScript({
url: 'https://cdn.example.com/library.js',
appendTo: 'head',
attributes: ["id=my-script", "data-custom=value"]
});
// Or inline script
await bstf.loadScript({
inlineScript: `console.log('Hello');`,
appendTo: 'body'
});
```
**Options:**
- `url` (string): URL of the script to load
- `inlineScript` (string): Inline JavaScript to execute
- `appendTo` (string|Element): Where to append ('head', 'body', or DOM element)
- `attributes` (array): Additional attributes ["key=value"]
#### loadStyle(options)
Dynamically inject CSS files or inline styles.
```javascript
await bstf.loadStyle({
url: 'https://cdn.example.com/styles.css',
appendTo: 'head'
});
// Or inline styles
await bstf.loadStyle({
inlineStyle: `.my-class { color: red; }`,
appendTo: 'head'
});
```
**Options:**
- `url` (string): URL of the stylesheet
- `inlineStyle` (string): Inline CSS to inject
- `appendTo` (string|Element): Where to append
#### videoEmbed(options)
Lazy-load video embeds (YouTube, Vimeo) with performance optimization.
#### videoPlayer(options)
Native video player with lazy loading and performance features.
---
### Trigger Events
#### onScroll(options)
Execute callbacks when user scrolls to a specific point.
```javascript
bstf.onScroll({
callback: () => {
console.log('User scrolled past threshold');
},
threshold: 500 // pixels from top
});
```
#### onClick(options)
Execute callbacks on element click.
```javascript
bstf.onClick({
selector: '.load-more-btn',
callback: async () => {
await bstf.loadScript({ url: 'heavy-feature.js' });
}
});
```
#### observer(options)
Execute callbacks when elements enter the viewport (Intersection Observer).
```javascript
bstf.observer({
options: { root: null, rootMargin: '0px', threshold: 0.5 },
element: document.querySelector('.lazy-component'),
callback: () => {
document.querySelector('.lazy-component').classList.add('visible');
}
});
// Destroy or refresh
bstf.destroyobserver({ element: document.querySelector('.lazy-component') });
bstf.refreshObserverEvents({ element: document.querySelector('.lazy-component') });
```
#### inactivity(options)
Detect user inactivity or browser idle state.
```javascript
// User idle mode - tracks mouse, keyboard, scroll
bstf.inactivity({
callback: () => {
console.log('User inactive for 5 seconds');
},
idleTime: 5000,
name: 'my-idle-detector'
});
// Native idle mode - uses requestIdleCallback
bstf.inactivity({
callback: () => {
performBackgroundTasks();
},
maxTime: 3000,
name: 'background-tasks'
});
// Destroy instance
bstf.destroyinactivity({ name: 'my-idle-detector' });
```
**Options:**
- `callback` (function): Function to execute
- `idleTime` (number): Ms of inactivity before triggering (user mode)
- `maxTime` (number): Maximum wait time in ms
- `events` (array|'none'): Events to monitor, or 'none' to disable
- `name` (string): Instance identifier (required for destroy)
- `debug` (boolean): Enable console logging
#### onLoad(options)
Execute callbacks after DOM/page load events. Best for third-party scripts.
---
## Common Use Cases
### Lazy Load Third-Party Scripts
```javascript
bstf.onScroll({
threshold: 100,
callback: async () => {
await bstf.loadScript({ url: 'https://analytics.com/script.js' });
}
});
```
### Load Heavy Features On-Demand
```javascript
bstf.onClick({
selector: '#open-chat',
callback: async () => {
await bstf.loadScript({ url: 'chat-widget.js' });
await bstf.loadStyle({ url: 'chat-widget.css' });
initChatWidget();
}
});
```
### Auto-Logout on Inactivity
```javascript
bstf.inactivity({
callback: () => {
if (confirm('Session expiring. Stay logged in?')) {
resetSession();
} else {
window.location.href = '/logout';
}
},
idleTime: 300000, // 5 minutes
name: 'session-timeout'
});
```
### Defer Non-Critical Work
```javascript
bstf.inactivity({
callback: () => {
prefetchNextPageAssets();
syncAnalyticsData();
},
events: 'none',
maxTime: 5000,
name: 'background-sync'
});
```
---
## Performance Benefits
- **Reduced Initial Load**: Load resources only when needed
- **Improved Core Web Vitals**: Better LCP, FID, CLS scores
- **Smart Resource Loading**: Trigger-based loading strategies
- **Browser-Friendly**: Uses native APIs like Intersection Observer and requestIdleCallback
================================================================================
COMPLETE DOCUMENTATION
================================================================================
## Guides
### Install
URL: https://boostifyjs.com/guides/install/
Description: Install Boostify in your project
Boostify is free and open source. No license required.
## How To install it?
You can install Boostify using npm or include it directly via CDN:
### npm
``` bash
npm install boostify
```
``` js
import Boostify from 'boostify';
const bstf = new Boostify({
debug: true
});
```
### CDN (UMD)
Include Boostify directly in your HTML:
``` html
Document
```
## Configuration
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `debug` | Boolean | `false` | Enable colorful console logging for debugging |
## Debug Mode
When `debug: true`, you'll see colorful logs in your browser console with emojis and gradients:
| Event | Emoji | Color |
|-------|-------|-------|
| Boostify init | đ | Purple gradient |
| OnLoad | ⥠| Purple/violet |
| Click | đ | Pink/coral |
| Scroll | đ | Green/turquoise |
| Observer | đď¸ | Cyan/blue |
| Inactivity | đ¤ | Pink/yellow |
| Script loaded | đŚ | Bright green |
| Style loaded | đ¨ | Pink |
This makes it easy to see exactly what Boostify is doing and when.
## What's Next?
With Boostify installed, you can:
- [Load third-party scripts efficiently](/trigger-events/on-load/) with the proxy feature
- [Trigger events on scroll](/trigger-events/on-scroll/)
- [Inject scripts on click](/trigger-events/on-click/)
- [Detect user inactivity](/trigger-events/inactivity/)
---
### Introduction
URL: https://boostifyjs.com/guides/introduction/
Description: Why Boostify?
Modern websites need to be **fast** â both in loading time and interaction.
I created this library with one main goal in mind: to make it easy for developers to **manage key performance features without adding complexity**. From injecting styles and scripts to embedding videos and triggering events at the right moment, everything is designed to be straightforward and developer-friendly.
One of the main challenges was bringing all these tools into a single, well-structured library. But doing so turned out to be incredibly useful â not only for improving performance but also for **simplifying development workflows**.
Since Google PageSpeed plays a big role in how sites are ranked, we also included a utility to fetch performance scores from your site with minimal setup.
## Feedback
We welcome all types of feedback â whether it's about improving the codebase, fixing bugs, or suggesting new features.
The goal is to build a tool that's truly helpful for everyone.
## Next steps
- [Install Boostify](/guides/install/) - Get started in minutes
- [On Load Events](/trigger-events/on-load/) - Defer third-party scripts
- [Load Scripts](/content-injection/load-script/) - Dynamic script injection
- [Load Styles](/content-injection/load-style/) - Dynamic CSS injection
## Use Boostify with Claude Code
Download the Boostify skill for Claude Code and get API-aware completions, pattern suggestions, and real-world examples directly in your editor.
⏠Download Claude Skill
## From the blog
- [Boostify is Now Free](/blog/boostify-is-now-free/) - Our open source announcement
- [Load Third-Party Scripts via Proxy](/blog/third-party-scripts-proxy/) - New proxy feature
- [Core Web Vitals and the Funnel](/blog/core-web-vitals-marketing-funnel/) - Why performance matters
================================================================================
## Content Injection Documentation
### Load Javascript
URL: https://boostifyjs.com/content-injection/load-script/
Description: Dynamically injects a javascript file into a page or adds elements using the
```
To this:
```html
```
### Step 3: Call onload
```js
bstf.onload({
worker: true,
callback: (result) => {
console.log('Scripts loaded!', result);
}
});
```
That's it. Your scripts now load without blocking your page.
---
## Complete Example
Here's a full example with Google Analytics:
```html
My Fast Website
```
---
## When Do Scripts Load?
Scripts load when **any** of these happen:
| Event | What it means |
|-------|---------------|
| User moves mouse | They're actively browsing |
| User scrolls | They're reading your content |
| User touches screen | Mobile interaction |
| Max time reached | Fallback after X milliseconds |
This means: scripts load when the user is engaged, not when they're waiting for your page.
---
## Configuration Options
```js
bstf.onload({
worker: true, // Use proxy (recommended)
maxTime: 2000, // Wait max 2 seconds
eventsHandler: ['mousemove', 'scroll', 'touchstart'],
callback: (result) => { }
});
```
| Option | Default | What it does |
|--------|---------|--------------|
| `worker` | `false` | `true` = load via Boostify proxy (faster, recommended) |
| `maxTime` | `600` | Max milliseconds to wait before loading anyway |
| `eventsHandler` | `['mousemove', 'load', 'scroll', 'touchstart']` | Which user actions trigger loading |
| `callback` | `null` | Function called when done |
---
## The `worker` Option Explained
When `worker: true`, Boostify loads scripts through our proxy server. This has two benefits:
1. **Faster loading**: Scripts are fetched in a separate thread
2. **No main thread blocking**: Your page stays responsive
```js
// Without worker (traditional)
bstf.onload({ worker: false }); // Scripts load directly from Google, Facebook, etc.
// With worker (recommended)
bstf.onload({ worker: true }); // Scripts load via Boostify's proxy
```
### Supported Services
The proxy works with all major tracking services:
| Service | Works? |
|---------|--------|
| Google Tag Manager | Yes |
| Google Analytics | Yes |
| Facebook Pixel | Yes |
| Microsoft Clarity | Yes |
| Hotjar | Yes |
| LinkedIn Insight | Yes |
| TikTok Analytics | Yes |
| jsDelivr, unpkg, cdnjs | Yes |
### What if my service is not listed?
Don't worry, you have options:
1. **Use `worker: false`** - Your scripts still load deferred, just not through the proxy:
```js
bstf.onload({ worker: false }); // Works with ANY script
```
2. **Request the domain** - Open an issue on [GitHub](https://github.com/andresclua/boostify/issues) and we'll add it to the proxy whitelist.
3. **Automatic fallback** - If you use `worker: true` with an unsupported domain, Boostify automatically falls back to traditional loading. Nothing breaks.
---
## Understanding the Callback
The callback tells you exactly what happened:
```js
bstf.onload({
worker: true,
callback: (result) => {
console.log(result);
}
});
```
Result example:
```js
{
success: true, // Did it work?
method: 'worker', // 'worker' or 'traditional'
loadTime: 245, // How long it took (ms)
triggeredBy: 'mousemove', // What triggered loading
scripts: [
{
url: 'https://googletagmanager.com/gtag/js',
success: true,
type: 'external',
proxied: true
},
{
success: true,
type: 'inline'
}
]
}
```
---
## Common Questions
### Will this break my analytics?
No. The scripts run exactly the same, just later. Your analytics will still track everything.
### Will I lose conversions?
You might see 0.5-2% fewer tracked pageviews on very fast bounces. But your site will be faster, which typically **increases** conversions overall.
### What if the proxy is down?
Boostify automatically falls back to traditional loading. Your scripts always load.
### Can I use this with any script?
Yes, but it's designed for third-party tracking scripts. Don't use it for scripts your page needs immediately (like React or Vue).
---
## More Examples
### Google Analytics 4
```html
```
### Facebook Pixel
```html
```
### Hotjar
```html
```
### Microsoft Clarity
```html
```
---
## Recommendation: Use Google Tag Manager
Instead of adding multiple scripts with `type="text/boostify"`, we recommend using **Google Tag Manager (GTM) as your single container**.
### Why?
1. **One script to load** - GTM loads once through the proxy, everything else loads inside GTM
2. **Easier management** - Add/remove tags from GTM's interface, no code changes needed
3. **Better performance** - One proxy request instead of multiple
4. **Full functionality** - All tags inside GTM work normally (cookies, tracking, pixels)
### How it works
```html
```
Then add all your other tags (Analytics, Facebook Pixel, Hotjar, HubSpot, etc.) inside GTM.
### What happens behind the scenes
1. Boostify loads GTM through the proxy (background, doesn't block)
2. GTM starts and loads your configured tags
3. Those tags load normally and work 100% (cookies, tracking, everything)
The key benefit: **GTM starts late**, so all its child tags also start late. Your page is already interactive before any tracking begins.
---
## Related
- [On Scroll Events](/trigger-events/on-scroll/) - Scroll-based triggers
- [Observer Events](/trigger-events/observer/) - Visibility-based triggers
- [On Click Events](/trigger-events/on-click/) - User interaction triggers
- [Inactivity Detection](/trigger-events/inactivity/) - User inactivity triggers
- [Load Script](/content-injection/load-script/) - Dynamic script injection
- [How to Load Analytics Without Slowing Down Your Site](/blog/third-party-scripts-proxy/) - Full guide
================================================================================
## FAQ
URL: https://boostifyjs.com/faq/
Is Boostify free?
Yes! Boostify is completely free and open source. No license key required, no subscriptions, no hidden costs. Just install and start optimizing your website performance.
Can I use Boostify in commercial projects?
Absolutely! Boostify is released under an open source license. You can use it in personal projects, commercial websites, WordPress themes, HTML templates, SDKs, or any other product without restrictions.
How does the proxy feature work?
When you use `worker: true` in the onLoad function, Boostify fetches third-party scripts through our proxy server (boostifyjs.com/proxy). This offloads the network request to a Web Worker, reducing main thread blocking and improving Core Web Vitals. The proxy supports popular services like Google Analytics, Facebook Pixel, Hotjar, and more.
What if my service is not in the proxy whitelist?
The proxy supports the most popular third-party services. If you need a service that's not currently supported, you can open an issue on our GitHub repository, and we'll consider adding it. In the meantime, you can still use `worker: false` for traditional loading.
Does Boostify work with WordPress?
Yes! You can include Boostify via CDN in your WordPress theme or use a custom JavaScript plugin to load it. It works great for deferring third-party scripts that slow down WordPress sites.
How can I contribute?
We welcome contributions! You can contribute by opening issues, submitting pull requests, improving documentation, or helping other users in our community. Check out our GitHub repository to get started.
How can I contact support?
For questions and support, you can reach us via GitHub issues or our Discord community. We're always happy to help!
## Related
- [Installation Guide](/guides/install/) - Get started with Boostify
- [On Load Events](/trigger-events/on-load/) - Learn about the proxy feature
- [Boostify is Now Free](/blog/boostify-is-now-free/) - Read about our open source journey
- [Third-Party Scripts Proxy](/blog/third-party-scripts-proxy/) - Deep dive into the proxy architecture
================================================================================
## Blog Articles
The following blog articles provide tutorials, best practices, and insights for web performance optimization with Boostify.
### Why Lighthouse Is a Marketing Tool, Not Just a Developer Checklist
URL: https://boostifyjs.com/blog/beyond-lighthouse-scores/
Description: Google Lighthouse doesnât just measure performanceâit reflects how your brand is perceived by users and search engines. CMOs should treat it as a strategic tool to drive visibility, trust, and growth.
Tags: SEO Strategy
Date: Tue Jul 25 2023 00:00:00 GMT+0000 (Coordinated Universal Time)
Ask most marketers what Google Lighthouse is, and youâll probably hear something like:
âAh, thatâs a dev thing, right? A performance report?â
Technically, yes. **But strategically, itâs much more than that.**
Lighthouse gives you a snapshot of how Googleâand your usersâexperience your site. It tells you if your page is slow to load, if it feels clunky to interact with, if content shifts unexpectedly, or if elements are blocking the userâs path to conversion.
**And all of that affects your visibility, your cost of acquisition, and your brand perception.**
A poor Lighthouse score is not just a red flag for your developers. Itâs a signal that your marketing investment isnât being delivered as promised. You may have the right messaging and audienceâbut if your landing page takes five seconds to render or shifts around while loading, youâve already lost the userâs trust before they even engage.
Letâs be blunt: Google takes this seriously. Core Web Vitals are part of the ranking algorithm. That means your organic traffic, SEO health, and even ad performance (yes, Quality Score matters) are all tied to these metrics.
And hereâs where smart tooling can change the game.
[Boostify](https://boostifyjs.com/) wasnât built for engineers who want cleaner code. It was built for businesses who want faster growth. It helps ensure that Lighthouse sees your site the way you want it to be seen: fast, interactive, and stable. No layout jumps. No render-blocking scripts. No user confusion.
Itâs not about chasing a perfect 100. Itâs about understanding what those scores represent:
- A fast **First Contentful Paint** = stronger first impressions
- Low **Cumulative Layout Shift** = higher trust and fewer bounces
- Fast **Time to Interactive** = smoother funnels and fewer drop-offs
In short, Lighthouse tells you **what your users feel but donât say**.
And if youâre in charge of growth, retention, or visibilityâ**you need to listen**.
Boostify helps you not just improve those scores, but translate them into real business outcomes. Because better performance doesnât just make your dev team happy. It makes your campaigns convert better, rank higher, and cost less.
That's not technical debt. **That's marketing lift**.
And it starts with how you read the signals Lighthouse is giving you.
---
## Related
- [Core Web Vitals and the Funnel](/blog/core-web-vitals-marketing-funnel/) - How performance metrics affect your entire user journey
- [The Business Case for Web Performance](/blog/website-performance-is-a-business/) - Why speed and stability are marketing tools
- [Load Third-Party Scripts Without Blocking](/blog/third-party-scripts-proxy/) - How to load analytics without hurting performance
- [On Load Event Documentation](/trigger-events/on-load/) - Defer third-party scripts to improve your scores
---
### Core Web Vitals and the Funnel: What Marketing Teams Canât Afford to Ignore
URL: https://boostifyjs.com/blog/core-web-vitals-marketing-funnel/
Description: From visibility to conversion, Core Web Vitals silently shape your marketing funnel. Hereâs how poor metrics like CLS, LCP, and FID can hurt performanceâand how to fix them.
Tags: Web Performance
Date: Wed Jul 26 2023 00:00:00 GMT+0000 (Coordinated Universal Time)
You probably donât think about **your marketing funnel** in terms of page speed.
But you should.
Because every second of delay, every visual shift, every lag between a tap and a responseâ**theyâre quietly breaking your funnel** in ways that analytics dashboards donât always reveal.
Letâs start at the top.
**Awareness**.
Your SEO strategy is driving traffic. But Googleâs algorithm favors pages with high Core Web Vitals scoresâspecifically LCP (Largest Contentful Paint), FID (First Input Delay), and CLS (Cumulative Layout Shift).
If your site scores poorly, **you rank lower**, show up less often, and pay more for the same visibility in search and ads.
Engagement.
Letâs say youâve won the click. But the hero image takes too long to load (poor LCP), or the layout shifts as elements render (high CLS). The user starts to scroll, tries to click a CTA, and the button jumps down the screen.
That momentâwhere they feel âthis site isnât ready for meââis enough to trigger doubt. And doubt kills engagement.
**Conversion**.
Hereâs where the funnel either worksâor leaks.
If your site lags when a user starts to interact (high FID), forms feel slow, animations stutter, or the experience just isnât smooth, the drop-off begins. Not because your offer wasnât good, but because your experience didnât match the userâs expectations.
The truth is: **Core Web Vitals are silent killers of conversion**.
They donât shout. They donât crash the page. But they make everything feel slightly offâand users donât stick around when things feel off.
Thatâs why treating performance like a backend issue is a mistake.
This is marketing territory.
And itâs exactly what [Boostify](https://boostifyjs.com/) was built for.
By restructuring how content loads, prioritizing speed, and eliminating layout shifts, Boostify helps your funnel flow the way you designed it. No code rewrites. No massive redesign. Just measurable improvements at every stepâfrom the first pixel to the final click.
Itâs time to treat performance not as technical debt, but as **funnel optimization**.
Because if your pages don't perform, your funnel doesn't either.
And if your funnel leaks, your growth stallsâno matter how brilliant the campaign.
---
## Related
- [Why Lighthouse Is a Marketing Tool](/blog/beyond-lighthouse-scores/) - Understanding Lighthouse as a strategic tool
- [The Business Case for Web Performance](/blog/website-performance-is-a-business/) - Why speed matters for your bottom line
- [Improve CLS with Image Dimensions](/blog/improve-cls-with-dimensions/) - Simple fix for layout shifts
- [On Load Event Documentation](/trigger-events/on-load/) - Defer scripts to improve Core Web Vitals
---
### Accessibility and Performance Are the Same Problem
URL: https://boostifyjs.com/blog/accessibility-and-performance/
Description: The techniques that make websites accessible to everyone also make them faster. Here's why the two goals are inseparable â and how optimizing for one automatically improves the other.
Tags: Accessibility, Performance, Web Development
Date: Wed Feb 18 2026 00:00:00 GMT+0000 (Coordinated Universal Time)
There's a version of this conversation that happens in a lot of teams:
The performance engineer says "we need to reduce JavaScript." The accessibility consultant says "we need proper focus management and ARIA roles." The project manager thinks these are two separate workstreams with two separate budgets.
They're not. **Most of the techniques that make a website accessible also make it faster.** Not as a side effect â as a direct consequence of building things in a simpler, more deliberate way.
## Semantic HTML is Faster HTML
When you use `