Search indexing should Ignore javascript in <SCRIPT> tags
douggreen - May 11, 2008 - 16:04
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | search.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
The search engine is indexing javascript inside of <SCRIPT> tags. See #257076.
The solution is to put script javascript inside an HTML comment. This is what we had to do in the 1990's when some browsers didn't support script. And I think it's still good practice.
<script><!-- --></script>
But the search engine should know that some people don't write good HTML, and should know to just skip these.

#1
It appears that drupal_add_js inline is not doing this, and I think it should. So a first step, is to get our own HTML to write the javascript inside an HTML comment.
#2
Although W3C says this works, this blog says that it doesn't. And the patch seems to break javascript on FF2. Guess it's back to just ignoring this in indexing.
#3
This method (<!-- -->) does work, ignore comment #2. The attached patch fixes the problem inherent in drupal_add_js, and adds a test case.
#4
CNW since #158992: Inline JavaScript is XHTML invalid commit.