把javascript放在标头之外有多糟糕? [英] How bad is it to put javascript outside of the header?

查看:138
本文介绍了把javascript放在标头之外有多糟糕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经说明了一切。



我开始向我的周末项目<​​/a>。这是一个很小的应用程序给我和几个朋友,因为我们交换学生对我们有用。



但事情是以下,我在做这在PHP和结构化所有包含所有我可以得到代码分离。这些代码中的一些代码依赖于javascripts狙击手,所以在身体的中间放置一个javascript有多糟糕?或者我应该做双重包括,所以javascript保持在标题?

解决方案

这不是坏的。

将脚本标签放在实际上是一个好习惯尽可能在页面


The question pretty much already says everything.

I'm starting to add some features to my weekend project. It's a small app for me and a couple of friends, as we're exchange students it's kinda useful for us.

But the thing is the following, I'm doing this in php and structuring everything with includes so i can get the code separated. Some of these pieces of code are dependent on javascripts snipets, so how bad is it to put a javascript in the middle of the body? Or should i just make double includes so the javascript stays in the header?

解决方案

It's not bad at all.

It's actually considered good practice to put your script tags as late as possible in the page.

这篇关于把javascript放在标头之外有多糟糕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆