External Scripts, with and without document.write statements, and a Cancelled Callback
See original GitHub issueHi
Thanks for the awesome library, really useful.
I’m trying to use PostScribe to manage script injection with external scripts, some of which may have document.write calls in them, some of which may not. At the moment I’m sending all of them through Postscribe because even if there’s no document.write statement it’s very important to maintain the order of the external scripts.
The problem I’m having is that when I send an external script without a document.write statement in it to Postscribe, I get back a cancel object and then Postscribe ceases to function, as you might expect.
In order to work out whether there’s a document.write statement in the script, I would have to find some way of downloading and searching the cross-domain scripts with some sort of regex, I guess. It seems like you’re already doing something better.
What would be even better from my point of view would be a cancelled
callback, which I can then work with and Postscribe would continue to perform its function for those external scripts that do have document write statements.
Tom
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (4 by maintainers)
Hi
OK so this was a timing issue. I was removing the first param targetnode from the page, after Postscribe checks for its presence but before the script was actually written to the page. So Postscribe just failed silently. Maybe another check for the target node before writing to the page? And maybe I should leave tidying up until I’ve actually got the whole thing working! Anyway, thanks for your time @jnewman
Tom
I’ll add a check in a future release