Skip to content

Instantly share code, notes, and snippets.

View danielpaul's full-sized avatar
🏠
Working from home

Daniel Paul danielpaul

🏠
Working from home
View GitHub Profile
@danielpaul
danielpaul / index.html
Created January 29, 2025 19:38
CookieChimp JS on SPA
<script is:inline>
function runCookieChimp() {
var script = document.createElement("script");
script.src = "http://localhost:3000/widget/K8ktWD.js";
script.id = "cookiechimp-js";
document.head.appendChild(script);
}
// for Astro JS.
// listen for other events for different frameworks.
@danielpaul
danielpaul / google_fonts.js
Created July 30, 2025 15:02
Load Google Fonts Based on Cookie Consent
function loadGoogleFonts(fontFamily = 'Open Sans') {
const link = document.createElement('link');
link.href = `https://fonts.googleapis.com/css2?family=${fontFamily.replace(/ /g, '+')}&display=swap`;
link.rel = 'stylesheet';
document.head.appendChild(link);
}
function removeGoogleFonts() {
const existingLink = document.querySelector('link[href^="https://fonts.googleapis.com/"]');
if (existingLink) {