Web components and polymer solve this problem "completly" by full encapsulation.
With some css preprocessing + vulcanizing you can even use separate js/css files from your component templates if that is your thing - they can get inlined in the build process.
I'm going through your tutorial at the moment and I think it's excellent. Now I'm considering buying the updated screencast. One question though. Is there any possibility for kindle friendly e-book?
Many Kindles can read PDFs, and the Rails Tutorial book is designed to look good on those. Eventually I may release a mobi format as well, but it's a pain to make, and I find that both mobi and ePub are rotten formats for technical books.