---
title: Boostify - Full Documentation
description: Complete documentation for Boostify JavaScript performance toolkit
version: latest
last_updated: 2026-01-31
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
## 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({
selector: '.lazy-component',
callback: (element) => {
element.classList.add('visible');
},
threshold: 0.5 // 50% visible
});
```
#### 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
## 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
No FAQ available.
================================================================================
## Blog Articles
The following blog articles provide tutorials, best practices, and insights for web performance optimization with Boostify.
### 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
---
### 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
---
### The Business Case for Web Performance: Why Speed and Stability Are Marketing Tools
URL: https://boostifyjs.com/blog/website-performance-is-a-business/
Description: Poor web performance doesnât just hurt UXâit drains budgets, damages SEO, and breaks trust. Here's why defining image dimensions and reducing layout shifts are essential for brand growth.
Tags: Web Performance
Date: Mon Jul 24 2023 00:00:00 GMT+0000 (Coordinated Universal Time)
We spend so much time perfecting our copy, refining ad creative, crafting the brand storyâyet we often overlook the single point where everything either works or fails: **performance**.
Because it doesnât matter how clever your message is if the page takes too long to appear. It doesnât matter how targeted your campaign is if the landing page shifts around as it loads.
**Performance isnât just a technical metric anymore. Itâs a business metric.**
And it affects every stage of your funnel.
Users today expect immediacy. They donât wait. A delay of more than two or three seconds? Thatâs enough to lose them. They might not even know why they leftâit just didnât feel smooth. And that feeling? It sticks. It becomes your brand.
Now zoom out. Think about the marketing dollars youâre investingâpaid campaigns, content strategies, SEO. If users land on a slow, unstable experience, **youâre not just losing conversions** **âyouâre losing trust and wasting budget.**
And then there's Google. With Core Web Vitals like **Cumulative Layout Shift (CLS)** now impacting search rankings, performance directly influences how visible you are in the first place. Pages that shift unexpectedly while loadingâoften because images are missing width and height attributesâget penalized. Thatâs not just a developer issue. Thatâs fewer impressions, less traffic, and reduced ROI.
This is where tools like [Boostify](https://boostifyjs.com/) come in.
Built for marketing outcomesânot just clean codeâBoostify restructures how assets load. It ensures your most important content appears quickly, defers anything that can wait, and stabilizes layout to reduce bounce-inducing shifts. It works alongside your stack, without requiring a costly rebuild.
You're not chasing a Lighthouse score for the sake of it. You're reclaiming budget that was leaking out of your funnel unnoticed. Youâre delivering on the promise your ads and emails make. Youâre removing the friction between curiosity and conversion.
Because in digital, **your siteâs speed is your first impression**.
And **stability is trust**.
If you're serious about growth, performance isnât optional.
Itâs foundational.
And Boostify helps you make it part of your marketing strategyânot just your codebase.
---
## Related
- [Core Web Vitals and the Funnel](/blog/core-web-vitals-marketing-funnel/) - How CLS, LCP, and FID affect your funnel
- [Why Lighthouse Is a Marketing Tool](/blog/beyond-lighthouse-scores/) - Lighthouse as a strategic business tool
- [Improve CLS with Image Dimensions](/blog/improve-cls-with-dimensions/) - Quick win for layout stability
- [Getting Started with Boostify](/guides/introduction/) - Start improving your performance today
---
### Boost Your UI with On-Demand CSS Libraries
URL: https://boostifyjs.com/blog/css-library-injection-tutorial/
Description: Learn how to dynamically load popular CSS libraries like Animate.css or Bootstrap to enhance your site without sacrificing initial load performance.
Tags: Coding, Performance, CSS, Animation
Date: Thu Jun 19 2025 00:00:00 GMT+0000 (Coordinated Universal Time)
# Dynamic CSS Library Injection: Enhanced UI Without the Wait
CSS libraries like Animate.css, Bootstrap, or Bulma can add powerful styling and animation capabilities to your site. However, loading these libraries upfront can significantly increase your initial page load timeâespecially when their features might only be needed for specific interactions.
## The Smart Approach: Load CSS Libraries On-Demand
With Boostify's content injection capabilities, you can load CSS libraries dynamically, exactly when you need them:
```js
(async () => {
try {
// Load Animate.css when user interacts with a specific element
document.getElementById('show-animation').addEventListener('click', async () => {
await bstf.loadStyle({
url: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css',
appendTo: 'head',
attributes: ["id=animate-css"],
});
console.log('Animate.css loaded successfully.');
// Now you can apply animation classes
document.getElementById('animated-element').className += ' animate__animated animate__bounce';
});
} catch (error) {
console.error(error);
}
})();
```
## The Benefits Are Clear
1. **Faster Initial Page Load**: Your core content loads quickly without being delayed by non-essential CSS.
2. **Better Performance Metrics**: Improve Core Web Vitals by deferring non-critical resources.
3. **On-Demand Effects**: Apply sophisticated animations and styles exactly when you need them.
## Real-World Use Cases
- **Product Showcases**: Load animation libraries when a user views product details
- **Interactive Tutorials**: Inject styling for tutorial steps only when a user reaches that section
- **Form Validation**: Load form-specific styling only when a user begins interacting with a form
## Before and After Example
**Before:** A static product card with basic styling.
**After:** After clicking "View Details", Animate.css is loaded and applied:
- The product image scales up with `animate__zoomIn`
- Feature highlights fade in with `animate__fadeInRight`
- The "Add to Cart" button pulses with `animate__pulse`
## Implementation Tips
- Group related CSS libraries to minimize the number of separate requests
- Consider preloading libraries for critical user paths where you know they'll be needed
- Use feature detection to load alternative libraries based on browser capabilities
By loading CSS libraries dynamically, you can create rich, engaging user experiences without compromising on initial page load performance.
## Related
- [Load Style Documentation](/content-injection/load-style/) - Complete API reference
- [On-Demand Tailwind CSS](/blog/tailwind-injection-tutorial/) - Load Tailwind dynamically
- [Custom CSS Injection](/blog/custom-css-injection-tutorial/) - Theme switching and visual enhancements
- [Dynamic jQuery Injection](/blog/jquery-injection-tutorial/) - Load JavaScript libraries on-demand
- [Smart Resource Loading](/blog/conditional-resource-loading-tutorial/) - Conditional loading strategies
---
### Enhancing Your Site with Dynamic jQuery Injection
URL: https://boostifyjs.com/blog/jquery-injection-tutorial/
Description: Learn how to load jQuery on-demand to add powerful functionality without impacting initial page load performance.
Tags: Coding, Performance
Date: Thu Jun 19 2025 00:00:00 GMT+0000 (Coordinated Universal Time)
# Dynamic jQuery Injection: Power Without the Performance Cost
jQuery remains one of the most versatile JavaScript libraries for DOM manipulation and animation effects. However, loading it upfront can unnecessarily slow down your initial page loadâespecially when its functionality is only needed for specific interactions.
## The Smart Approach: Load jQuery On-Demand
With [Boostify's content injection capabilities](/content-injection/load-script/), you can load jQuery dynamically, exactly when you need it:
```js
(async () => {
try {
await bstf.loadScript({
url: 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js',
appendTo: 'head',
attributes: ["id=jquery", "data-test=1"],
});
console.log('jQuery loaded successfully.');
// Now you can use jQuery!
$('body').css('background-color', '#f0f8ff');
$('.header').animate({
opacity: 0.8
}, 1000);
} catch (error) {
console.error(error);
}
})();
```
Check out the [complete loadScript documentation](/content-injection/load-script/#configuration-options) to see all available configuration options.
## The Benefits Are Clear
1. **Faster Initial Page Load**: Your core content loads quickly without being blocked by non-essential scripts.
2. **Better Performance Metrics**: Improve Core Web Vitals by deferring non-critical resources.
3. **On-Demand Power**: Access jQuery's powerful features exactly when you need them.
## Real-World Use Cases
- **Interactive Forms**: Load jQuery only when a user focuses on a complex form
- **Image Galleries**: Inject jQuery when a user clicks to view a gallery
- **Animation Effects**: Add subtle animations after the main content has loaded
## Implementation Tips
- Wrap your jQuery code inside the success callback to ensure it only runs after the library has loaded
- Consider adding a loading indicator if the functionality is user-initiated
- Test on slower connections to ensure a smooth experience for all users
- For more advanced script loading techniques, check out our [detailed content injection guide](/content-injection/load-script/)
By loading jQuery dynamically, you get the best of both worlds: fast initial page loads and the rich functionality of jQuery when you need it.
## Related
- [Load Script Documentation](/content-injection/load-script/) - Complete API reference
- [Load Third-Party Scripts via Proxy](/blog/third-party-scripts-proxy/) - Load analytics without blocking
- [On-Demand Tailwind CSS](/blog/tailwind-injection-tutorial/) - Dynamically inject Tailwind CSS
- [On-Demand CSS Libraries](/blog/css-library-injection-tutorial/) - Load animation libraries on-demand
- [Custom JavaScript Injection](/blog/custom-js-injection-tutorial/) - Advanced injection techniques
- [Smart Resource Loading](/blog/conditional-resource-loading-tutorial/) - Conditional loading strategies
---
### On-Demand Tailwind CSS: Load Styles When You Need Them
URL: https://boostifyjs.com/blog/tailwind-injection-tutorial/
Description: Learn how to dynamically inject Tailwind CSS into your pages for enhanced styling without the initial performance cost.
Tags: Coding, Performance
Date: Thu Jun 19 2025 00:00:00 GMT+0000 (Coordinated Universal Time)
# Dynamic Tailwind CSS Injection: Style Without the Weight
Tailwind CSS offers an incredible utility-first approach to styling, but including the full framework upfront can add unnecessary weight to your initial page loadâespecially when those styles might only be needed for specific components or interactions.
## The Smart Approach: Load Tailwind On-Demand
With [Boostify's content injection capabilities](/content-injection/load-style/), you can load Tailwind CSS dynamically, exactly when you need it:
```js
(async () => {
try {
// Load the Tailwind CSS from CDN
await bstf.loadStyle({
url: 'https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css',
appendTo: 'head',
attributes: ["id=tailwind-css"],
});
console.log('Tailwind CSS loaded successfully.');
// Now you can apply Tailwind classes dynamically
document.getElementById('my-element').className += ' bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded';
} catch (error) {
console.error(error);
}
})();
```
Check out the [complete loadStyle documentation](/content-injection/load-style/#configuration-options) to see all available configuration options.
## The Benefits Are Clear
1. **Faster Initial Page Load**: Your core content loads quickly without being weighed down by unused CSS.
2. **Better Performance Metrics**: Improve Core Web Vitals by deferring non-critical resources.
3. **On-Demand Styling**: Apply Tailwind's powerful utility classes exactly when you need them.
## Real-World Use Cases
- **Modal Windows**: Load Tailwind when a user triggers a modal that needs complex styling
- **Advanced UI Components**: Inject Tailwind for rich components that aren't part of the initial view
- **User Preferences**: Apply different Tailwind themes based on user selections
## Implementation Tips
- Consider loading a subset of Tailwind that only includes the utilities you need
- Use the `preload` attribute for critical UI elements that will appear shortly after page load
- Combine with responsive loading strategies to deliver different styles based on device capabilities
- For more advanced style loading techniques, check out our [detailed content injection guide](/content-injection/load-style/)
By loading Tailwind CSS dynamically, you maintain the flexibility and power of utility classes while ensuring your core content loads quickly and efficiently.
## Related
- [Load Style Documentation](/content-injection/load-style/) - Complete API reference
- [Dynamic jQuery Injection](/blog/jquery-injection-tutorial/) - Load jQuery on-demand
- [On-Demand CSS Libraries](/blog/css-library-injection-tutorial/) - Load animation libraries on-demand
- [Custom CSS Injection](/blog/custom-css-injection-tutorial/) - Theme switching and visual enhancements
- [Smart Resource Loading](/blog/conditional-resource-loading-tutorial/) - Conditional loading strategies
- [Core Web Vitals and the Funnel](/blog/core-web-vitals-marketing-funnel/) - Why performance matters for conversions
---
### Transform Your UI with Dynamic CSS Injection
URL: https://boostifyjs.com/blog/custom-css-injection-tutorial/
Description: Learn how to load custom CSS styles on-demand to enhance your site's appearance without impacting initial page load performance.
Tags: Coding, Performance, CSS, Styling
Date: Thu Jun 19 2025 00:00:00 GMT+0000 (Coordinated Universal Time)
# Dynamic Custom CSS Injection: Beautiful Styling When You Need It
Custom CSS can transform your website's appearance and create visually engaging experiences. However, loading all your styles upfront can significantly increase your initial page load timeâespecially when certain styles might only be needed for specific sections or user interactions.
## The Smart Approach: Inject Custom CSS On-Demand
With Boostify's content injection capabilities, you can load custom CSS styles dynamically, exactly when you need them:
```js
(async () => {
try {
// Load custom CSS when a specific user action occurs
document.getElementById('toggle-dark-mode').addEventListener('click', async () => {
// Option 1: Load from an external file
await bstf.loadStyle({
url: '/assets/css/dark-theme.css',
appendTo: 'head',
attributes: ["id=dark-theme"],
});
// Option 2: Insert inline CSS
await bstf.loadStyle({
inlineStyle: `
body {
background-color: #121212;
color: #e0e0e0;
}
.card {
background-color: #1e1e1e;
border: 1px solid #333;
box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}
.button {
background-color: #bb86fc;
color: #000;
}
.button:hover {
background-color: #9966cc;
}
`,
appendTo: 'head'
});
console.log('Dark mode styles loaded successfully.');
});
} catch (error) {
console.error(error);
}
})();
```
## The Benefits Are Clear
1. **Faster Initial Page Load**: Your core content loads quickly without being delayed by non-essential styles.
2. **Better Performance Metrics**: Improve Core Web Vitals by deferring non-critical CSS.
3. **On-Demand Styling**: Apply sophisticated visual enhancements exactly when you need them.
4. **Reduced Rendering Complexity**: Keep your initial render process simpler and faster.
## Real-World Use Cases
- **Theme Switching**: Load dark/light mode styles only when a user toggles the theme
- **Print Styles**: Inject print-specific CSS only when a user initiates printing
- **Advanced Animations**: Load complex animation styles only when elements enter the viewport
- **Specialized UI Components**: Apply component-specific styles only when those components are activated
## Before and After Example
**Before:** A standard light-themed interface with basic styling.
**After:** After clicking "Enable Dark Mode":
- Background shifts to a dark color scheme
- Text becomes lighter for better contrast
- UI elements receive subtle glow effects
- Accent colors adjust for better visibility in dark mode
## Implementation Tips
- Use CSS variables to make theme switching more efficient
- Consider using media queries within your injected CSS for responsive adjustments
- Prioritize critical styles in your initial CSS and defer non-essential styles
- Test your dynamic styling on various devices to ensure consistent experiences
By injecting custom CSS dynamically, you can create visually rich, adaptable interfaces without compromising on initial page load performance.
## Related
- [Load Style Documentation](/content-injection/load-style/) - Complete API reference
- [On-Demand Tailwind CSS](/blog/tailwind-injection-tutorial/) - Load Tailwind dynamically
- [On-Demand CSS Libraries](/blog/css-library-injection-tutorial/) - Load animation libraries on-demand
- [Smart Font Fallbacks](/blog/smart-font-fallbacks-tutorial/) - Reduce CLS with font optimization
- [Improve CLS with Image Dimensions](/blog/improve-cls-with-dimensions/) - Prevent layout shifts
---
### Supercharge Your Site with Custom JavaScript Injection
URL: https://boostifyjs.com/blog/custom-js-injection-tutorial/
Description: Learn how to dynamically load custom JavaScript code to add powerful functionality without bloating your initial page load.
Tags: Coding, Performance, JavaScript
Date: Thu Jun 19 2025 00:00:00 GMT+0000 (Coordinated Universal Time)
# Dynamic Custom JavaScript Injection: Powerful Functionality When You Need It
Custom JavaScript can add powerful interactivity and functionality to your website. However, loading all your JavaScript upfront can significantly increase your initial page load time and potentially introduce unnecessary complexityâespecially when certain features might only be needed in specific scenarios.
## The Smart Approach: Inject Custom JS On-Demand
With Boostify's content injection capabilities, you can load custom JavaScript code dynamically, exactly when you need it:
```js
(async () => {
try {
// Load custom JS when a specific user action occurs
document.getElementById('show-chart').addEventListener('click', async () => {
// Option 1: Load from an external file
await bstf.loadScript({
url: '/assets/js/chart-generator.js',
appendTo: 'body',
attributes: ["id=chart-js"],
});
// Option 2: Execute inline JavaScript
await bstf.loadScript({
inlineScript: `
// Create a simple chart
const ctx = document.getElementById('chart-container').getContext('2d');
const data = [12, 19, 3, 5, 2, 3];
const labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'];
// Draw the chart using canvas
ctx.beginPath();
ctx.moveTo(0, 100 - data[0] * 4);
for(let i = 1; i < data.length; i++) {
ctx.lineTo(i * 50, 100 - data[i] * 4);
}
ctx.stroke();
// Add labels
for(let i = 0; i < labels.length; i++) {
ctx.fillText(labels[i], i * 50, 120);
}
`,
appendTo: 'body'
});
console.log('Chart functionality loaded successfully.');
});
} catch (error) {
console.error(error);
}
})();
```
## The Benefits Are Clear
1. **Faster Initial Page Load**: Your core content loads quickly without being delayed by non-essential JavaScript.
2. **Better Performance Metrics**: Improve Core Web Vitals by deferring non-critical code.
3. **On-Demand Functionality**: Add complex features exactly when you need them.
4. **Reduced Memory Usage**: Keep your page's memory footprint smaller until additional functionality is needed.
## Real-World Use Cases
- **Data Visualization**: Load chart-generating code only when a user navigates to the analytics section
- **Advanced Form Validation**: Inject form validation logic only when a user begins filling out a form
- **Interactive Maps**: Load mapping functionality only when a user requests location information
- **Social Media Widgets**: Add social sharing capabilities only after content has been fully loaded
## Implementation Tips
- Use feature detection to ensure compatibility before loading custom code
- Consider breaking complex functionality into smaller, more focused modules
- Add error handling to gracefully degrade if script loading fails
- Use performance monitoring to measure the impact of your dynamic loading strategy
By injecting custom JavaScript dynamically, you can create sophisticated, feature-rich experiences without compromising on initial page load performance.
## Related
- [Load Script Documentation](/content-injection/load-script/) - Complete API reference
- [Load Third-Party Scripts via Proxy](/blog/third-party-scripts-proxy/) - Load analytics without blocking
- [Dynamic jQuery Injection](/blog/jquery-injection-tutorial/) - Load jQuery on-demand
- [Smart Resource Loading](/blog/conditional-resource-loading-tutorial/) - Conditional loading strategies
- [On Load Events](/trigger-events/on-load/) - Defer scripts to improve performance
---
### Preventing CLS with Proper Image Dimensions
URL: https://boostifyjs.com/blog/improve-cls-with-dimensions/
Description: Why defining width and height on images is essential for reducing Cumulative Layout Shift (CLS) and improving Lighthouse performance scores.
Tags: CLS
Date: Mon Jul 24 2023 00:00:00 GMT+0000 (Coordinated Universal Time)
One of the most frustrating visual issues on the web is when content shifts around as the page loads. This is known as **Cumulative Layout Shift (CLS)** â and it directly affects your Lighthouse score and user experience.
CLS is part of Google's [Core Web Vitals](https://web.dev/cls/), and it measures layout stability. A high CLS means users are seeing elements jump around, which can lead to accidental clicks and a sense of jankiness.
## What Causes CLS?
A common reason for layout shifts is when images (or ads, embeds, fonts, etc.) load in **without predefined dimensions**. If the browser doesn't know the size of the image, it can't reserve space for it â so once the image loads, the layout jumps.
## The Fix: Set `width` and `height` on Images
To prevent this, **always add `width` and `height` attributes to your `` tags**. This lets the browser calculate the correct aspect ratio and reserve the right amount of space before the image is downloaded.
### â Bad Example
```html
```
### â Good Example
```html
```
This defines the imageâs size and prevents unexpected layout changes.
### What About Responsive Images?
Even if you're using responsive layouts, you should still include width and height attributes. The browser will use those values to calculate the aspect ratio, then scale the image with CSS.
```css
img {
width: 100%;
height: auto;
}
```
This keeps your design fluid while preserving layout stability.
### Using aspect-ratio in CSS
If youâre using modern CSS, another option is to use the aspect-ratio property:
```css
img {
aspect-ratio: 4 / 3;
width: 100%;
height: auto;
}
```
This is especially useful for background images or media rendered dynamically with JavaScript.
### Quick Tips to Improve CLS
- Use `width` and `height` on all `` elements.
- Reserve space for embeds (e.g. iframes, videos) using wrappers with fixed aspect ratios.
- Avoid injecting DOM elements above existing content during load.
- Test your site using Lighthouse or Chrome DevTools â Performance tab.
- Keep CLS below 0.1 for a good Core Web Vitals score.
### Conclusion
Preventing layout shifts is key to improving both user experience and performance metrics. Adding width and height to your images is one of the easiest ways to achieve that.
A stable layout not only looks better â it also feels faster and more professional.
## Related
- [Core Web Vitals and the Funnel](/blog/core-web-vitals-marketing-funnel/) - How CLS affects your conversions
- [The Business Case for Web Performance](/blog/website-performance-is-a-business/) - Why stability matters
- [Why Lighthouse Is a Marketing Tool](/blog/beyond-lighthouse-scores/) - Understanding performance metrics
- [On Load Events](/trigger-events/on-load/) - Defer scripts to improve CLS
---
### Smart Font Fallbacks: Eliminate Layout Shifts with CSS Font Descriptors
URL: https://boostifyjs.com/blog/smart-font-fallbacks-tutorial/
Description: Learn how to use CSS font descriptors to create intelligent fallbacks that prevent layout shifts while maintaining your design integrity.
Tags: Performance, Web Fonts, Core Web Vitals
Date: Wed Jan 08 2025 00:00:00 GMT+0000 (Coordinated Universal Time)
# Smart Font Fallbacks: Eliminate Layout Shifts with CSS Font Descriptors
Layout shifts caused by web font loading are silent conversion killers. Users see content jump around as fonts load, creating a jarring experience that screams "unprofessional." But there's a better way than choosing between `font-display: swap` (which causes shifts) and `font-display: optional` (which might show system fonts).
## The Real Problem with Font Loading
When browsers load web fonts, they initially render text using system fallbacks. Once the web font downloads, the browser swaps it inâoften changing the text's dimensions and causing everything below to shift. This directly impacts your Cumulative Layout Shift (CLS) score and user experience.
The traditional approach was to accept this trade-off. Not anymore.
## CSS Font Descriptors: The Game Changer
CSS font descriptors (f-mods) let you override the metrics of fallback fonts to match your web fonts exactly. By adjusting `ascent-override`, `descent-override`, and `line-gap-override`, you can make system fonts behave like your custom fontsâeliminating layout shifts entirely.
Here's how it works in practice:
```css
/* Fallback fonts with custom metrics */
@font-face {
font-family: 'Syne-fallback';
src: local('Trebuchet MS');
ascent-override: 92.5%;
descent-override: 27.5%;
line-gap-override: 0%;
}
@font-face {
font-family: 'HubotSans-fallback';
src: local('Courier New');
ascent-override: 109%;
descent-override: 32%;
line-gap-override: 0%;
}
/* Your actual web fonts */
@font-face {
font-family: "Syne";
src: url('/fonts/Syne/Syne-VariableFont_wght.woff2') format('woff2'),
url('/fonts/Syne/Syne-VariableFont_wght.woff') format('woff');
font-style: normal;
font-weight: 400 800;
font-display: fallback;
}
@font-face {
font-family: "Hubot Sans";
src: url('/fonts/HubotSans/HubotSans-VariableFont_wdth,wght.woff2') format('woff2'),
url('/fonts/HubotSans/HubotSans-VariableFont_wdth,wght.woff') format('woff');
font-style: normal;
font-weight: 200 900;
font-display: fallback;
}
```
## How to Calculate the Right Values
The magic is in getting the override values right. You need your web font's metrics, which you can extract from the font file itself:
1. **Get the TTF file** of your web font
2. **Use FontDrop.info** to analyze the font metrics
3. **Find the HHEA table** values: ascender, descender, line-gap
4. **Calculate percentages** based on unitsPerEm
For example, if your font has:
- unitsPerEm: 1000
- ascender: 925
- descender: 275
Your CSS would be:
```css
ascent-override: 92.5%; /* 925/1000 */
descent-override: 27.5%; /* 275/1000 */
line-gap-override: 0%;
```
## Integrating with Dynamic Loading
This technique pairs perfectly with [Boostify's dynamic font loading](/content-injection/load-style/). You can load fonts on-demand while ensuring zero layout shift:
```js
// Load fonts dynamically with Boostify
await bstf.loadStyle({
url: '/fonts/custom-fonts.css',
appendTo: 'head'
});
// Your fallbacks are already preventing layout shifts
// while the web fonts load in the background
```
## The Performance Impact
Smart fallbacks deliver measurable improvements:
- **Zero CLS from font swaps**: Fallbacks match web font dimensions exactly
- **Faster perceived performance**: Content renders immediately with proper spacing
- **Better Core Web Vitals**: Improved CLS scores boost search rankings
- **Maintained design integrity**: Users see your intended typography, not random system fonts
## Browser Support and Progressive Enhancement
CSS font descriptors work in Chrome 87+ and Safari 14.1+. Firefox support is coming. Since this is a progressive enhancement, unsupported browsers simply get the standard fallback behaviorâno harm done.
```css
/* This works everywhere */
body {
font-family: "Syne", "Syne-fallback", sans-serif;
}
/* Enhanced browsers get perfect fallbacks */
/* Older browsers get standard system fonts */
```
## Implementation Tips
1. **Test across operating systems**: Fallback fonts vary between Windows, macOS, and Linux
2. **Use variable fonts when possible**: Single file, multiple weights, better performance
3. **Preload critical fonts**: Combine with `` for fastest loading
4. **Monitor your metrics**: Track CLS improvements in your analytics
## Real-World Results
Sites implementing smart fallbacks typically see:
- 40-60% reduction in CLS scores
- Improved user engagement metrics
- Better search rankings due to Core Web Vitals improvements
- Maintained design consistency across all loading states
Smart font fallbacks aren't just a technical optimizationâthey're a user experience upgrade that protects your brand while boosting performance metrics.
## Related
- [Improve CLS with Image Dimensions](/blog/improve-cls-with-dimensions/) - Another quick CLS fix
- [The Business Case for Web Performance](/blog/website-performance-is-a-business/) - Business impact of layout shifts
- [Core Web Vitals and the Funnel](/blog/core-web-vitals-marketing-funnel/) - How CLS affects conversions
- [On-Demand CSS Libraries](/blog/css-library-injection-tutorial/) - Dynamic CSS loading techniques
- [Load Style Documentation](/content-injection/load-style/) - CSS loading API reference
---
### Smart Resource Loading: Load What You Need, When You Need It
URL: https://boostifyjs.com/blog/conditional-resource-loading-tutorial/
Description: Learn how to conditionally load resources based on user interactions, device capabilities, and other factors to optimize performance.
Tags: Coding, Performance, Optimization, JavaScript
Date: Thu Jun 19 2025 00:00:00 GMT+0000 (Coordinated Universal Time)
# Conditional Resource Loading: The Smart Way to Optimize Performance
Modern websites often require numerous resourcesâJavaScript libraries, CSS frameworks, fonts, and moreâto deliver rich experiences. However, loading everything upfront can significantly impact performance, especially on slower connections or less powerful devices.
## The Smart Approach: Load Resources Conditionally
With Boostify's content injection capabilities, you can implement sophisticated conditional loading strategies:
```js
(async () => {
try {
// Example 1: Load based on user interaction
document.getElementById('open-chat').addEventListener('click', async () => {
await bstf.loadScript({
url: 'https://cdn.example.com/chat-widget.js',
appendTo: 'body',
});
});
// Example 2: Load based on viewport/element visibility
const observer = new IntersectionObserver(async (entries) => {
if (entries[0].isIntersecting) {
await bstf.loadStyle({
url: 'https://cdn.example.com/advanced-animations.css',
appendTo: 'head',
});
observer.disconnect(); // Load only once
}
});
observer.observe(document.querySelector('.animation-container'));
// Example 3: Load based on device capabilities
if (window.matchMedia('(min-width: 768px)').matches) {
// Load desktop-specific enhancements
await bstf.loadScript({
url: '/assets/js/desktop-features.js',
appendTo: 'body',
});
} else {
// Load mobile optimizations
await bstf.loadScript({
url: '/assets/js/mobile-optimizations.js',
appendTo: 'body',
});
}
// Example 4: Load based on user preferences
if (localStorage.getItem('prefers-advanced-features') === 'true') {
await bstf.loadScript({
url: '/assets/js/advanced-features.js',
appendTo: 'body',
});
}
} catch (error) {
console.error(error);
}
})();
```
## The Benefits Are Clear
1. **Optimized Performance**: Load only what users actually need based on their context.
2. **Better User Experience**: Prioritize critical resources first, then enhance progressively.
3. **Reduced Data Usage**: Save bandwidth by avoiding unnecessary resource downloads.
4. **Device-Appropriate Experiences**: Deliver the right experience for each device type.
## Real-World Use Cases
- **Chat Widgets**: Load chat functionality only when a user clicks the chat icon
- **Media-Rich Content**: Load high-resolution images or videos only on capable devices
- **Advanced Interactions**: Add sophisticated UI behaviors only when users scroll to that section
- **Feature Toggles**: Enable experimental features only for users who opt in
## Implementation Strategies
### 1. User Interaction-Based Loading
Load resources in response to specific user actions:
```js
element.addEventListener('click', async () => {
await bstf.loadScript({ url: 'resource.js' });
// Initialize newly loaded functionality
});
```
### 2. Visibility-Based Loading
Load resources when elements come into view:
```js
const observer = new IntersectionObserver(async (entries) => {
if (entries[0].isIntersecting) {
await bstf.loadStyle({ url: 'animations.css' });
}
});
observer.observe(element);
```
### 3. Capability-Based Loading
Adapt loading based on device capabilities:
```js
if ('IntersectionObserver' in window && 'requestIdleCallback' in window) {
// Load advanced features for modern browsers
} else {
// Load fallback for older browsers
}
```
### 4. Preference-Based Loading
Respect user preferences for resource loading:
```js
if (localStorage.getItem('data-saver') === 'true') {
// Load lightweight alternatives
} else {
// Load standard resources
}
```
By implementing conditional resource loading strategies, you can create websites that are both feature-rich and highly performant, adapting to each user's unique context and needs.
## Related
- [Load Script Documentation](/content-injection/load-script/) - Complete API reference
- [Load Style Documentation](/content-injection/load-style/) - CSS loading API
- [Observer Events](/trigger-events/observer/) - Visibility-based loading with Boostify
- [On Load Events](/trigger-events/on-load/) - Defer third-party scripts
- [Dynamic jQuery Injection](/blog/jquery-injection-tutorial/) - Load libraries on-demand
- [On-Demand CSS Libraries](/blog/css-library-injection-tutorial/) - Load CSS dynamically
---
### Boostify is Now Free & Open Source
URL: https://boostifyjs.com/blog/boostify-is-now-free/
Description: We're removing the license requirement. Boostify is now completely free to use.
Tags: Announcements
Date: Thu Jan 29 2026 00:00:00 GMT+0000 (Coordinated Universal Time)
We are pleased to announce that Boostify is transitioning to a fully open source model, effective immediately.
After several years of development and working closely with the developer community through performance consulting engagements, we have gained valuable insights into how teams approach web performance optimization. These experiences have shaped our vision for Boostify's future.
We believe that the best way to grow this project and maximize its impact is to remove all barriers to adoption. **Starting today, Boostify is completely free to use.** No license keys, no subscription fees, no usage limits.
This transition also means we are opening our doors to the community. Building and maintaining a performance library of this scope requires collaboration. We are actively seeking contributors who share our commitment to making the web fasterâwhether through code contributions, documentation improvements, bug reports, or feature suggestions.
If you've been waiting for the right moment to try Boostify, this is it.
```js
const bstf = new Boostify({ debug: true });
```
Just install and use it.
## What's changing?
| Before | Now |
|--------|-----|
| $5/month license | Free forever |
| License key required | No license needed |
## What's NOT changing?
- All features remain the same
- Documentation stays updated
- Bug fixes and improvements continue
- Discord community stays active
## New: Proxy for third-party scripts
Along with going free, we're releasing a new feature: load your analytics and tracking scripts through our proxy, keeping your main thread free:
```js
bstf.onload({
worker: true,
callback: (result) => {
console.log('Loaded in', result.loadTime, 'ms');
}
});
```
[Read more about the proxy feature â](/blog/third-party-scripts-proxy/)
## Support the project
Boostify is built and maintained by one developer. If it saves you time or helps your projects, consider buying me a coffee:
**[Sponsor on GitHub â](https://github.com/sponsors/andresclua)**
Your support keeps the project alive and the proxy servers running.
## Thank you
To everyone who purchased a license before: thank you for believing in this project early on.
To everyone trying Boostify for the first time: welcome.
---
## Get started
- [Installation Guide](/guides/install/) - Get Boostify running in minutes
- [Introduction](/guides/introduction/) - Learn what Boostify can do
- [On Load Events](/trigger-events/on-load/) - Defer third-party scripts
## Community
- [Discord](https://discord.gg/zHseJ3sw8J)
- [GitHub](https://github.com/andresclua/boostify)
- [Sponsor](https://github.com/sponsors/andresclua)
---
### How to Load Google Analytics Without Slowing Down Your Website
URL: https://boostifyjs.com/blog/third-party-scripts-proxy/
Description: Learn how to load third-party scripts like Google Analytics, Facebook Pixel and Hotjar without blocking your website's main thread.
Tags: Performance, Analytics, Guide
Date: Sat Jan 31 2026 00:00:00 GMT+0000 (Coordinated Universal Time)
Every website needs tracking. Google Analytics to understand your users. Facebook Pixel for ads. Hotjar to see how people interact with your site.
But here's the problem: every script you add makes your website slower.
## What Happens When You Add a Script
When you add Google Analytics the normal way:
```html
```
Your browser has to stop everything it's doing. It connects to Google's servers, downloads the script, and processes it. During this time, your website can't respond to users.
Click a button? Nothing happens. Try to scroll? It stutters.
This is called **blocking the main thread**.
## What is the Main Thread?
Think of your browser as having one worker who does everything: painting the page, responding to clicks, running animations, loading scripts.
When you add a third-party script, that worker has to stop serving your users and go fetch something from another server. Users wait.
Now imagine you could hire a second worker who handles all the fetching in a back room, while the first worker stays focused on your users.
That's exactly what Boostify does.
## How Boostify Solves This
Instead of loading scripts the normal way, you change one small thing. Your script goes from this:
```html
```
To this:
```html
```
The only difference is `type="text/boostify"`.
This tells Boostify: "Don't load this script normally. Put it in the background."
## What Happens Behind the Scenes
When you use `type="text/boostify"`, Boostify:
1. **Waits** until your page is ready and the user starts interacting
2. **Sends a helper** (called a Web Worker) to fetch the script
3. **Routes the request** through our proxy server (because browsers have security rules about loading scripts from other domains)
4. **Injects the script** only after your page is fully interactive
Your main thread never stops. Your users never wait. The scripts still load and work perfectlyâthey just don't block anything.
## Complete Example
Here's how to set up Google Analytics without slowing down your site:
```html
My Fast Website
Welcome
```
## Works With All Major Services
You can use `type="text/boostify"` with:
- Google Analytics
- Google Tag Manager
- Facebook Pixel
- Microsoft Clarity
- Hotjar
- LinkedIn Insight Tag
- TikTok Pixel
- HubSpot
- Any script from jsDelivr, unpkg, or cdnjs
## The Difference You'll Feel
| Without Boostify | With Boostify |
|------------------|---------------|
| Page loads, then freezes while scripts download | Page loads and stays responsive |
| Buttons feel delayed | Buttons respond instantly |
| Scroll stutters | Scroll is smooth |
| Users leave frustrated | Users stay and convert |
## Why a Proxy?
Browsers have security rules that prevent loading scripts from other websites in the background. It's a protection mechanism.
Boostify's proxy acts as a trusted middleman. Your site asks our proxy, our proxy gets the script from Google (or Facebook, or wherever), and delivers it back. The browser trusts this because it comes from a single, known source.
The proxy is free, fast, and handles millions of requests.
## Our Recommendation: Use Google Tag Manager
Instead of adding `type="text/boostify"` to multiple scripts, we recommend using **Google Tag Manager (GTM) as your single container**.
Why? Because you only need to load one script through Boostify:
```html
```
Then add all your other tags (Facebook Pixel, Hotjar, HubSpot, etc.) inside GTM's interface.
**Benefits:**
- One proxy request instead of many
- Easier to manage (no code changes to add/remove tags)
- Everything works normally (cookies, tracking, pixels)
GTM loads late through Boostify, which means all the tags inside GTM also start late. Your page is already interactive before any tracking begins.
## Start Now
1. Add `type="text/boostify"` to your GTM script (or individual scripts if you prefer)
2. Include Boostify at the end of your page
3. Call `bstf.onload({ worker: true })`
That's it. Your analytics work exactly the same, but your site stays fast.
## Related
- [On Load Documentation](/trigger-events/on-load/) - Full configuration options
- [Boostify is Now Free](/blog/boostify-is-now-free/) - No license needed
- [Core Web Vitals and Your Marketing Funnel](/blog/core-web-vitals-marketing-funnel/) - Why speed affects conversions
- [Beyond Lighthouse Scores](/blog/beyond-lighthouse-scores/) - Real performance matters
================================================================================
## Additional Resources
- GitHub Issues: https://github.com/andresclua/boostify/issues
- NPM Package: https://www.npmjs.com/package/boostify
For condensed documentation suitable for smaller context windows, see: https://boostifyjs.com/llms.txt