Avatar of MJ
Flag for United States of America asked on

Kill Image Request taking too long using JS?

Is there a way to monitor and then kill a server request for an image (preferably in JavaScript) if it is taking too long? The image comes from a 3rd party server so I'd have to kill it on the request side. I'm asking due to us firing 3rd party marketing pixels on our web app. Sometimes they take extreme amounts of time to respond.
Web DevelopmentJavaScript* http response

Avatar of undefined
Last Comment

8/22/2022 - Mon
David Favor

Maybe say what you're trying to accomplish or problem to correct.

1) If pixel takes to long, when visitor leaves site, request will die, so no action is required.

2) If pixel is interferring with page render, move the pixel embed code to your document footer.

3) If document footer relocation fails, then wrap pixel in Javascript, to request only begins after page is rendered.

There isn't any impact to our site other than the reports that are generated on page load times to our execs. Yes, I've explained DOM content loaded etc. but it doesn't matter.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
David Favor

Well... If it has no impact... ignore it...

Or, if you prefer getting this... "off your reports"... then use the #3 option above, so have some Javascript fire on "Document Ready", to fetch the pixel in background.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck

One issue is I don't create the calls or have control over the format/ structure. The calls are automatically generated by our analytics code (Adobe). The image requests are for transparent 2 x 2 px. gifs. They use the trojan horse (beacon technology) approach (query string on img request has the info attached using a query string.