更新时间:2023-12-05 10:36:34
不同的浏览器对此有不同的看法。有些只在包含 src
且没有错误的情况下运行内容。有些人在尝试包含 src
脚本后运行它,无论成功与否。由于此行为不可靠(并在HTML5中禁止) ,应该避免。
Different browsers treat this differently. Some run the content only if the src
is included without error. Some run it after attempting to include the src
script, regardless of success. Since this behaviour is unreliable (and prohibited in HTML5), it should be avoided.
Google并不依赖于任何特定行为。由于内容只是一个对象文字(一个值),执行它实际上不会做任何事情,除了导致无声错误。 Google的代码会查看脚本
标记本身的内容,并根据该标记调整其行为。
Google isn't relying an any specific behaviour. Since the content is just an object literal (a value), executing it would not actually do anything except cause a silent error. Google's code looks at the contents of the script
tag itself, and adjust its behaviour based on that.