Skip to content

Instantly share code, notes, and snippets.

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

Hamid Reza Nikoonia HamidReazaNikoonia

🏠
Working from home
View GitHub Profile
@mberneti
mberneti / retryDynamicImport.ts
Last active November 11, 2024 05:32
This utility function retryDynamicImport enhances React’s lazy loading mechanism by adding retry logic with a versioned query parameter. It retries importing a component multiple times in case of failure, which can be useful for bypassing browser cache or dealing with intermittent network issues. It can be used as a drop-in replacement for React…
// Usage:
// Replace React.lazy(() => import('x'));
// with retryDynamicImport(() => import('x'));
import { ComponentType, lazy } from 'react';
const MAX_RETRY_COUNT = 15;
const RETRY_DELAY_MS = 500;
// Regex to extract the module URL from the import statement
@HamidReazaNikoonia
HamidReazaNikoonia / gist:504dc1090fefad5c4079131c1b151669
Created December 2, 2021 02:56
How Controll UI Layout for LTR & RTL direction
// left-to-right
<html lang="en" dir="ltr">
// right-to-left
<html lang="ar" dir="rtl">
// Customize with CSS
html:lang(ar) {
@tomhicks
tomhicks / plink-plonk.js
Last active November 12, 2024 19:08
Listen to your web pages