X (Twitter)

Discord

GitHub1.1k
2.81 min read

v1.1.2 โ€” Optimistic UI & Bundle Optimization

Posted By

Christopher Burns
Consent Team
Christopher Burns

Major Changes

This release introduces optimistic UI updates and achieves massive bundle size reduction while adding a new headless package for maximum flexibility.

๐Ÿ”ง Fixes & Improvements

@c15t/react@1.1.2

Improved UX responsiveness for banner and dialog interactions:

  • UI now updates immediately on user interaction (e.g., closing modals, accepting/rejecting consent), with consent saved in the background
  • This ensures a smoother experience, especially on slower connections or when network requests are delayed

Improved event handling for ConsentButton:

  • Rewritten logic to separate UI updates from consent persistence
  • Custom onClick handlers now receive the full MouseEvent, enabling better control and integration

Cleaner store logic:

  • Refactored setShowPopup and saveConsents methods to better separate UI vs network logic
  • More consistent behavior around locale changes and popup visibility

c15t@1.0.5

โš™๏ธ Under the Hood:

  • Improved consent flow by decoupling UI updates from async network calls โ€” UI now responds instantly, with API sync happening in the background
  • Fixed an edge case where popup visibility or dialog state could behave inconsistently due to dependency timing
  • Minor cleanup and better error handling in consent persistence logic

๐Ÿš€ Performance Revolution

Bundle Size Optimization

  • MASSIVE: Reduced package size from 84.2 kB โ†’ 34.6 kB (gzip) โ€” a 58.9% reduction
  • Removed framer-motion dependency for lighter bundle
  • Replaced Tailwind variants with native transitions and utility classes
  • Zero compromise on UX while achieving faster load times

๐Ÿง  New Headless Package

@c15t/react/headless

  • NEW: Introduced @c15t/react/headless for teams who need full UI control
  • Ultra-lightweight: Only 12.5 kB (gzip) footprint
  • Perfect for custom implementations and design systems
  • Complete access to consent logic without built-in UI components

โœจ What's Changed

Full Changelog: 1.1.1...1.1.2

๐Ÿ“‹ Implementation Details

// Optimistic consent flow
const handleConsent = async (choice) => {
  // 1. Update UI immediately (optimistic)
  updateUIState(choice);
  
  // 2. Save to backend (background)
  try {
    await saveConsent(choice);
  } catch (error) {
    // 3. Revert UI if needed
    revertUIState();
  }
};

Enhanced Event Handling

<ConsentButton 
  onClick={(event: MouseEvent) => {
    // Full access to mouse event
    // Custom logic before/after consent handling
    handleCustomAnalytics(event);
  }}
>
  Accept Cookies
</ConsentButton>

๐Ÿงช Testing

Test Plan

โœ… Scenario 1: Clicking the "Accept All" button on cookie banner

  • Expected: Banner immediately disappears, consent is saved in the background

โœ… Scenario 2: Testing on slow networks

  • Using Chrome DevTools to simulate slow 3G connection
  • Expected: UI updates immediately regardless of network speed

Edge Cases

  • Error handling: If the network request fails, the UI is already updated, and errors are logged
  • Performance: Significant improvement in perceived performance on all device types

This release makes c15t leaner, faster, and more flexible than ever while maintaining full backward compatibility and enhancing the user experience through optimistic UI updates.

Thank you to our contributors

c15t.com