 Understand the JavaScript SEO basics
A good search engine shouldn't process JS at all, and index only the content that is reachable via links pulled from HTML (which may, of course, be dynamic).<p>The processing of JS explains a lot of the sheer garbage that is in the Google results.<p>I think they do it because it ties into their business model. JS is needed to unearth the kind of crap that a certain segment of the user base is looking for. That certain segment is worth catering to because it consists of users who are likely to click on ads.<p>Otherwise, nobody in their right mind would integrate JS into a crawler.  "I'm going to write a program that automatically finds random source code, much of it malicious, and runs it!" Come on; without a business agenda justifying it, it's a complete non-starter.