admin管理员组文章数量:1305230
I am teaching an HTML5 class and one student did this for his header:
<script src="elements/header.js"></script>
<script>
header("Home");
</script>
The linked file looks like this:
function header(name){
document.write(`
<header
style="
text-align: center;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
"
>
<h1>Science Fiction</h1>
<h2>${name}</h2>
</header>
<hr />
`);
}
He also did this for the footer and navbar. It works, but in all my years of web development, I've never seen it done this way. For one thing, I see no reason to include CSS in a linked JavaScript file when you could just put it in a linked CSS file. But beyond that, I'm wondering if web developers don't do this because it might affect SEO. Does dynamically linking to content prevent that content from being indexed by search engines? This is for a student project so SEO doesn't matter, just wondering from a best practices standpoint.
本文标签: htmlDoes dynamically loading header content via a linked JavaScript file affect SEOStack Overflow
版权声明:本文标题:html - Does dynamically loading header content via a linked JavaScript file affect SEO? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741797806a2398040.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论