Skip to content

Instantly share code, notes, and snippets.

View mberneti's full-sized avatar
🎯
Focusing

mohammadreza berneti mberneti

🎯
Focusing
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
import { useState } from 'react';
import classnames from 'classnames';
import { Box } from './Box'; // Assuming Box component is imported from a file
interface Slide {
[key: string]: any;
}
interface AttachElementsType {
isSimple: boolean;
metric material-ui and design tailwindcss
Loading 3 ms 18 ms 3 ms
Scripting 49 ms 35 ms 18 ms
Rendering 2 ms 6 ms 2 ms
metric material-ui ant design tailwindcss
First Contentful Paint 0.4 s 0.5 s 0.4 s
Largest Contentful Paint 0.4 s 0.5 s 0.4 s
Time to Interactive 0.4 s 0.5 s 0.4 s
size file
41.55 KB build\static\js\2.5aa3c038.chunk.js
1.83 KB build\static\css\main.e89c07d1.chunk.css
848 B build\static\js\runtime-main.e78c30e6.js
552 B build\static\js\main.1f8bd29a.chunk.js
size file
64.22 KB build\static\css\2.d4e7eff5.chunk.css
63.71 KB build\static\js\2.a4e2ff05.chunk.js
848 B build\static\js\runtime-main.b3febbbe.js
528 B build\static\js\main.25f39053.chunk.js
303 B build\static\css\main.d9b5e89a.chunk.css
size file
62.14 KB build\static\js\2.821814f2.chunk.js
784 B build\static\js\runtime-main.cbc14a35.js
530 B build\static\js\main.3ec4d24c.chunk.js
304 B build\static\css\main.de44605d.chunk.css
@mberneti
mberneti / PHP Version Manager On Ubuntu 20.04 and nginx.txt
Last active July 10, 2020 17:13
PHP Version Manager On Ubuntu 20.04 and nginx
Get the information of PHP
==========================
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:ondrej/nginx
sudo add-apt-repository ppa:ondrej/php
// The installation of php on Ubuntu configures Apache.
@mberneti
mberneti / Immutable JS Examples
Created May 30, 2018 23:37 — forked from singhshivam/Immutable JS Examples
Immutable JS Examples
List()
var list = Immutable.List([1,2,3])
// [1, 2, 3]
List.isList()
Immutable.List.isList(list)
// true
List.of()
var list = Immutable.List.of(1,2,3);