This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* NEVER BLOCKING LOOP : implementation of the infamous setTimeout 0 hack, with time checking in order to guarantee fluidity without sacrificing execution speed. | |
* | |
* USAGE : | |
* var array = ["a way too big array that is heavy to process"] | |
* optimizeFor({ | |
* nbIterations: array.length, | |
* each:function( index ) { | |
* doSomethingUsefulWith( array[ index ] ); | |
* }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const timings = performance.getEntriesByType('navigation')[0] | |
const allEntries = performance.getEntries() | |
const customMetrics = allEntries | |
.filter(entry => ['mark', 'measure'].includes(entry.entryType )) // array of PerformanceMark / PerformanceMeasure objects | |
.reduce((final, current) => { // make an object | |
final[current.entryType.toUpperCase() + ' — ' + current.name] // key name : "MARK — loadInAsync que/query_grid_webpart start" | |
= Math.round( | |
current.entryType === 'measure' ? current.duration : current.startTime | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
let lazyModalComponent; | |
let isPending = false; | |
function openModal() { | |
isPending = true; | |
lazyModalComponent = import(`./Modal.svelte`); | |
lazyModalComponent.catch((error) => { | |
// gestion en cas d'erreur de connexion ici | |
}).finally(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { lazy, useState, useTransition } from 'react'; | |
import { ErrorBoundary } from 'react-error-boundary'; | |
const Modal = lazy(() => import('./Modal.jsx')); | |
export default function App() { | |
const [isPending, startTransition] = useTransition(); | |
const [opened, setOpened] = useState(false); | |
function openModal() { |
OlderNewer