哪里是放的JavaScript / AJAX文档中的最好的地方? [英] Where is the best place to put JavaScript/Ajax in a document?

查看:101
本文介绍了哪里是放的JavaScript / AJAX文档中的最好的地方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

道歉的愚蠢的冠冕堂皇的问题,但我需要的专家澄清。

Apologies for the dumb sounding question, but I need the experts to clarify.

出了三地把Javascript中, $(文件)。就绪,其中,将最好的地方是把一些Ajax,使用了大量的 $ GET 功能?

Out of the three places to put Javascript, head, $(document).ready, or body, where would the best place be to put some ajax that uses a lot of $GET functions?

比如我现在用所谓的JavaScript函数 execute_send(),但我不能确定其中最好的地方把它将会是。以下是错误:

For instance I am using a JavaScript function called execute_send() but I am unsure where the best place to put it would be. Below is the error:

在行67字符22问题:execute_send是用它被定义之前。 功能execute_send(){

Problem at line 67 character 22: 'execute_send' was used before it was defined. function execute_send() {

另外如何安置影响页面加载时间?

Also how does the placement affect the page loading time?

推荐答案

在一般情况下,除非出于某种原因,你在其他地方需要它,把你所有的JS最后在体内。该浏览器将不会继续下去,直到它分析你的JS,所以它是好的,让网页加载第一。请参阅<一href="http://developer.yahoo.com/performance/rules.html">http://developer.yahoo.com/performance/rules.html

In general, unless for some reason you need it elsewhere, put all of your JS last in the body. The browser won't continue until it's parsed your JS, so it is nice to let the page load first. See http://developer.yahoo.com/performance/rules.html

这篇关于哪里是放的JavaScript / AJAX文档中的最好的地方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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