Your problem may be one of the deadlines.
Keep in mind that when you call something like $('a').attr(...whatever...) , it will act instantly on any and all existing elements on the page. So, if your tweet plugin is asynchronous and takes more than 0 milliseconds, it looks like your code is trying to change the attributes on links that do not yet exist on the page.
That is, you can (A) call the tweet plugin, (B) change all the links on the page, and then (C) the tweet plugin will complete and add a bunch of new links on the page that was received previously missed.
So, what could you try, see if your tweet plugin uses some βdoneβ or other completion callback that you could use to change link tags. Or, like the other answer you proposed, which I also approve of, you should not just try to change the link tags, but instead listen (live) on any link, click on the page and intercept them at this point in time. This way you don't have to worry about the time / completion of the tweet plugin, as you can use event delegation ( live ), which works at any given time. See the answer from Petah for a great example of how to do this.
Good luck
Funka
source share