I have content that is added to divs via javascript like this:
<script>
//This is generated via PHP
var contents = [ "Item 1", "Item 2" ];
//Set the first item to show
document.getElementById( "item" ).textContent = contents[ 0 ];
</script>
Is the value "Item 1" crawlable? (ie the text content set by JS on the div "item")
Please take a look at this link enter link description here
It says that in is in the works and
In the past few months, our indexing system has been rendering a substantial number of web pages more like an average user's browser with JavaScript turned on.
Google now executes JavaScript somewhat like a simple browser:
In order to solve this problem, we decided to try to understand pages by executing JavaScript . It's hard to do that at the scale of the current web, but we decided that it's worth it. We have been gradually improving how we do this for some time. In the past few months, our indexing system has been rendering a substantial number of web pages more like an average user's browser with JavaScript turned on.
In your example, item 1 is crawlable. Too complex JavaScript won't be executed, though:
Sometimes the JavaScript may be too complex or arcane for us to execute, in which case we can't render the page fully and accurately.
The old method for indexing dynamic content is to put it in the HTML code of the page, and make the script extract it for dynamic use. This has the side advantage of allowing JavaScript-disabled visitors to see your content - in a crude form, but that's better than nothing, since a significant portion of visitors have JavaScript turned off . They may do that for security reasons, or because their device doesn't support JavaScript. So when you can, put important content in HTML rather than in your script: even if it is less important than before for SEO, it's still useful.
No google bots do no crawl javascript created contents
Bots don't run scripts. best practices to keep your content as html for seo
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.