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

Detecting and handling blocked scripts #47

Open
michaelroper opened this issue Jun 6, 2017 · 5 comments
Open

Detecting and handling blocked scripts #47

michaelroper opened this issue Jun 6, 2017 · 5 comments

Comments

@michaelroper
Copy link

michaelroper commented Jun 6, 2017

Hey! I'm trying to figure out how to detect and handle if an external tracker script has been blocked by Ghostery/AdBlock - but my test code below only ever seems to trigger success, even if I'm using Ghostery to explicitly block the Marketo script (and I don't see that script load in DevTools either). Am I doing it wrong?

loadjs(['https://munchkin.marketo.net/munchkin-beta.js'], 'marketo');
loadjs.ready('marketo', {
    success: function() {
        console.log('pass!');
    },
    error: function(depsNotFound) {
        console.log('fail!');
    }
});
</script>
@amorey
Copy link
Member

amorey commented Jun 6, 2017

Do you know the mechanism that the blocker is using to block the script? Currently, LoadJS is configured to detect script blocking via the defaultPrevented mechanism:
https://github.com/muicss/loadjs/blob/master/src/loadjs.js#L164-L169

@michaelroper
Copy link
Author

Hey Andres - not sure what the mechanism is, this was testing with Ghostery on Chrome/Mac. Interestingly, I just installed Ghostery on Safari/Mac, blocked Marketo, and it DID throw the error... so I'm not sure what the difference is. Have I coded that correctly for this situation?

@amorey
Copy link
Member

amorey commented Jun 6, 2017

Yes, you're coding it correctly. Do you know of any JS libraries that can detect script blocking by Ghostery/Adblock in all browsers?

@michaelroper
Copy link
Author

Hmm, to be honest, I've actually never looked. ¯_(ツ)_/¯

@amorey
Copy link
Member

amorey commented Jun 6, 2017

Ok, I'll look for a library that can detect script blocking by Ghostery/Adblock. Let me know if you find something sooner.

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