Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose if loading failed because of an error or because of a blocker #50

Open
danrr opened this issue Jul 12, 2017 · 11 comments
Open

Expose if loading failed because of an error or because of a blocker #50

danrr opened this issue Jul 12, 2017 · 11 comments

Comments

@danrr
Copy link

danrr commented Jul 12, 2017

Hi! I'm using loadjs (great library btw) and I'm seeing some infrequent loading failures in the logs. I'm trying to establish if it's caused by something blocking the scripts or if they are failing to load for some other reason.

The loadFiles function already has logic to detect blocked scripts but it does not expose this information, only which scripts were blocked, if any. I'd like to be able to add this to the logs to better diagnose the what causing the failed script loads.

What do you think?

@amorey
Copy link
Member

amorey commented Jul 12, 2017

Are you trying to determine if a script was blocked by an ad blocker or something else?

@danrr
Copy link
Author

danrr commented Jul 12, 2017

Yes, I'd like to know if it was blocked by an ad blocker. Particularly, if a script was added to pathsNotFound by the logic here https://github.com/muicss/loadjs/blob/master/src/loadjs.js#L166.

@amorey
Copy link
Member

amorey commented Jul 12, 2017

It should be easy to modify the library to return that information but I'm not sure we can reliably detect blocked scripts so I've actually been thinking about removing that code from the library altogether (unless we can fix it). Here's the github issue:
#47

@danrr
Copy link
Author

danrr commented Jul 12, 2017

OK, I see. I did look at that issue before posting but didn't know you were looking to remove the detection. Has there been any additional testing to verify that the detection isn't working or if it's specific browser/ad blocker combos that it doesn't work for?

@amorey
Copy link
Member

amorey commented Jul 12, 2017

I haven't had a chance to look too closely at the issue yet. Do you know of any libraries that can detect blocked scripts that work across browsers/adblocker?

@danrr
Copy link
Author

danrr commented Jul 12, 2017

Sorry, I don't know of any off the top of my head.

@danrr
Copy link
Author

danrr commented Jul 12, 2017

I might have a play with different adblockers and browsers when I get some time, and report back with any findings.

@amorey
Copy link
Member

amorey commented Jul 13, 2017

Great! Let me know.

@danrr
Copy link
Author

danrr commented Jul 16, 2017

I tested uBlock, Adblock, Adblock Plus, and Ghostery on Chrome, Firefox, and Safari (all on Mac).
Only Safari triggered the beforeload event with defaultPrevented and it did it for all blockers. All other browsers just triggered an error event. Does that match what you were expecting?

@amorey
Copy link
Member

amorey commented Jul 16, 2017

Great, thanks for doing the research! I guess that answers the question about whether or not we can detect if a script was blocked by an ad blocker or if the download failed for another reason.

I'm still concerned about our ability to detect all blocked scripts as highlighted in this issue: #47

@danrr
Copy link
Author

danrr commented Jul 16, 2017

I've not seen the issue described in #47. Loadjs always fired the correct success/error callback in my tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants