
40k?
I'll admit that I know nothing about adsense specifically but why the hell does it need to be 40k? Surely it's just a matter of: send token to Google, get back response, parse response into DOM and insert?
You can do that in a much smaller amount of code - the server should be doing all the work after all. Much like Opera Mini - the part the user has is just a front end to the server's response.
I've written Twitter stuff which does just that. Doesn't tie up the page at all.