Skip to main content

Bundle Size

Adgent SDK is optimized for Smart TV platforms with minimal footprint:

Gzipped

< 20 KBProduction build with compression

Minified

~50 KBMinified but not compressed

Dependencies

1 packageOnly fast-xml-parser
From CHANGELOG.md:
  • ESM bundle: 9.3 KB gzipped
  • UMD bundle: 7.3 KB gzipped
  • Target: ES2020 for Smart TV runtime compatibility

Size Comparison

How Adgent SDK compares to alternatives:
LibraryGzipped SizeDependenciesVAST 4.xSmart TV
Adgent SDK< 20 KB1
Video.js + IMA~150 KB20+⚠️
JW Player~180 KBMany⚠️
Shaka Player + Ads~200 KB15+⚠️
Custom VAST parserVaries3-5⚠️⚠️
Adgent SDK is 7-10x smaller than typical video player + ad SDKs, making it ideal for Smart TV platforms where bundle size directly impacts load time.

Why Bundle Size Matters on Smart TVs

Smart TVs often have:
  • 2.4GHz WiFi only (older models)
  • Weak signal in living room location
  • Limited bandwidth (5-20 Mbps common)
Impact: A 20 KB SDK downloads in 0.3s vs 150 KB competitor downloading in 2.4s on 5 Mbps connection.
  • Budget TVs: 512MB - 1GB RAM
  • Mid-range TVs: 1.5GB - 2GB RAM
  • Premium TVs: 3GB - 4GB RAM
Impact: Smaller JavaScript bundles leave more memory for video buffers and UI rendering.
Smart TV JavaScript engines are 3-8x slower than desktop browsers:
  • Tizen: JavaScriptCore (older version)
  • WebOS: V8 (older version)
  • Vidaa: Custom engine
Impact: Parsing 20 KB takes ~50ms vs 150 KB taking ~400ms on budget TVs.
Smart TV apps must:
  • Load quickly (users expect less than 3s)
  • Display content immediately
  • Avoid “Loading…” screens
Impact: Smaller SDK = faster app startup and better user experience.

Optimization Techniques

1. Enable Tree Shaking

Use ES modules to eliminate unused code:
vite.config.js
export default {
  build: {
    rollupOptions: {
      output: {
        manualChunks: undefined
      }
    }
  }
};
Only import what you need:
// Good: Tree-shakeable named imports
import { AdgentSDK, getPlatformAdapter } from 'adgent-sdk';

// Avoid: Namespace imports prevent tree shaking
import * as Adgent from 'adgent-sdk';

2. Lazy Load the SDK

Load the SDK only when ads are about to play:
// Lazy load SDK when user starts video
async function playVideoWithAd() {
  // Start content preload immediately
  const contentPromise = loadContentVideo();
  
  // Load ad SDK in parallel
  const { AdgentSDK } = await import('adgent-sdk');
  
  const sdk = new AdgentSDK({
    container: document.getElementById('ad-container'),
    vastUrl: 'https://example.com/vast.xml'
  });
  
  await sdk.init();
  
  // Resume content after ad
  await contentPromise;
  playContent();
}
This approach reduces initial bundle size by 20 KB and only loads the ad SDK when needed.

3. Code Splitting

Split your app code from ad code:
// routes.ts
const routes = [
  {
    path: '/video/:id',
    component: () => import('./pages/VideoPlayer.vue')
  },
  {
    path: '/browse',
    component: () => import('./pages/Browse.vue') // No ad SDK in browse
  }
];

4. VAST Caching

Reduce network requests by caching VAST responses:
const vastCache = new Map<string, VASTResponse>();

async function getVAST(url: string) {
  if (vastCache.has(url)) {
    const cached = vastCache.get(url)!;
    // Check if cache is still fresh (e.g., < 5 minutes old)
    if (Date.now() - cached.timestamp < 300000) {
      return cached.data;
    }
  }
  
  const response = await fetch(url);
  const xml = await response.text();
  
  vastCache.set(url, {
    data: xml,
    timestamp: Date.now()
  });
  
  return xml;
}
Don’t cache VAST responses for too long—ad inventory changes frequently. Use a TTL of 5-10 minutes maximum.

5. Bitrate Selection

Set appropriate targetBitrate for your platform:
import { getPlatformAdapter } from 'adgent-sdk';

const adapter = getPlatformAdapter();

// Adjust bitrate based on device capabilities
let targetBitrate = 2500; // Default 1080p

if (adapter.capabilities.maxResolution === '720p') {
  targetBitrate = 1500; // Lower bitrate for 720p TVs
} else if (adapter.capabilities.maxResolution === '4k') {
  targetBitrate = 4000; // Higher bitrate for 4K TVs
}

const sdk = new AdgentSDK({
  container: document.getElementById('ad-container'),
  vastUrl: 'https://example.com/vast.xml',
  targetBitrate
});

6. Preconnect to Ad Servers

Reduce DNS/TLS handshake time:
<!-- Add to <head> -->
<link rel="preconnect" href="https://vast.example.com">
<link rel="preconnect" href="https://tracking.example.com">
<link rel="dns-prefetch" href="https://cdn.example.com">

Performance Checklist

1

Use ES modules

Import from adgent-sdk using named imports for tree shaking
2

Enable minification

Use production builds with Terser/UglifyJS/esbuild minification
3

Lazy load when possible

Dynamic import the SDK only when ads are needed
4

Cache VAST responses

Implement in-memory or localStorage caching with TTL
5

Set appropriate bitrate

Use targetBitrate: 1500-2500 for Smart TVs
6

Preconnect to ad domains

Add <link rel="preconnect"> for VAST and tracking URLs
7

Test on real devices

Measure load time and memory usage on actual Smart TVs

Benchmarks

Load Time (Slow 3G, 400ms latency)

ScenarioTimeNotes
SDK Download0.3s20 KB @ 5 Mbps
SDK Parse0.05sES2020 on Tizen TV
VAST Fetch1.2s5 KB XML @ 5 Mbps + 400ms latency
Init + Autoplay0.5sVideo element creation + muted autoplay
Total2.05sFirst ad frame on screen

Memory Usage

ComponentMemoryNotes
SDK Code~0.5 MBJavaScript heap
VAST Parser~0.2 MBXML parsing + data structures
Video Element~5-15 MBDepends on resolution/bitrate
Tracking~0.1 MBEvent listeners + fetch queues
Total~6-16 MBWell within TV constraints
For comparison, typical web video players consume 30-80 MB of memory on Smart TVs.

Platform-Specific Tips

// Tizen TVs benefit from explicit codec checks
const adapter = getPlatformAdapter();

if (adapter.isCodecSupported('video/mp4; codecs="avc1.4d401f"')) {
  // Use H.264 Main Profile Level 3.1
  targetBitrate = 2500;
} else {
  // Fallback to lower profile
  targetBitrate = 1500;
}

See Also

Build docs developers (and LLMs) love