JSFiddle - React, Tailwind, and code Playground

by Will Alexander

HTML

<html> 
    <head> 
        <title> jQuery.globalEval Delayed in Firefox </title> 
    </head >
    <body> 
        <h1> jQuery.globalEval Delayed By Inserted Scripts </h1> 
        <p> 
            Time taken: <b id=timetaken></b> 
        </p> 
        <hr/> 
        <p> 
            A globalEval() script will be called and insert the duration between the call to globalEval() and the execution of the script. Immediately prior to the globalEval() call, a dynamic script will also be inserted that takes two seconds to complete.  
        </p> 
        <p> 
            Since Firefox executes scripts in the order in which they're inserted, the time taken will be ~5 seconds.  All other browsers will execute the script synchronously.

JavaScript

var 
    startTime= window.startTime= Number (new Date), 
    delayed= document.createElement("script"), 
    global= "time= Number(new Date) - startTime; ; $('#timetaken').html(time + 'ms') ", 

        delayUrl= 'http://a.ec2-1.digital-fulcrum.com/?delay=5&x-async=false&x-order=1&cache-control=no-cache'
; 
delayed.src= delayUrl; 
document.body.appendChild( delayed ); 
jQuery.globalEval(global);