简体   繁体   English

我的javascript没有按顺序加载

[英]my javascript is not loading in order

I think I'm going crazy, all my searches indicate I am doing this properly, but I am still getting the opposite results. 我想我会发疯,我所有的搜索都表明我正在做这件事,但我仍然得到了相反的结果。 I have two scripts. 我有两个脚本。 The first one is the library (RecordRTC), and the second one is my javascript using the library. 第一个是库(RecordRTC),第二个是我使用库的javascript。 No matter what I do, my script loads first - and the library loads second. 无论我做什么,我的脚本首先加载 - 然后库加载第二个。 And my browser keeps showing (in the timeline) that this is true, and my script keeps showing the error "RecordRTC not defined" - that my script is calling the library before it has loaded. 我的浏览器一直显示(在时间轴中)这是真的,我的脚本一直显示错误“RecordRTC not defined” - 我的脚本在加载之前调用了库。

Below is ALL the html code I'm using. 下面是我正在使用的所有html代码。 Please send help. 请发送帮助。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Testing RecordRTC</title>
<script type='text/javascript' src="http://RecordRTC.org/latest.js"></script>
</head>
<body>
    <div id="videos-container">
        <video id="video"></video>
    </div>
  <script type='text/javascript' src="./js/videos02.js" defer></script>
</body>
</html>

Use a validator . 使用验证器

async and defer are boolean attributes. asyncdefer是布尔属性。 They are either present or they are omitted. 它们要么存在要么被省略。 You cannot give them the values true and false . 你不能给它们true值和false值。 async=false is an error that will be error corrected to async is on for this script . async=false是一个错误,将错误更正为此脚本的async已启用

The library is being called before it is loaded because you have said that it can be loaded async and defer so the browser isn't waiting for it before loading the other script. 该库在加载之前被调用,因为您已经说过它可以加载异步并延迟,因此浏览器在加载其他脚本之前不会等待它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM