Loading a library from an URL versus local
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
When I load the library from an url, my code works as intended but when I try to load the same library from my local drive it spits out the error:
Uncaught ReferenceError: quat is not defined
at main (main.js:3)
at onload (index.html?_ijt=h48f9s7rceh7l34tfquh6ab8n5:7)
main @ main.js:3
onload @ index.html?_ijt=h48f9s7rceh7l34tfquh6ab8n5:7
What am I doing wrong in second case?
//index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body onload="main()">
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js"></script>-->
<script src="Libraries/gl-matrix.js"></script>
<script src="main.js"></script>
</body>
</html>
//main.js
function main()
{
let x = quat.create();
console.log(x);
}
html
|
show 1 more comment
When I load the library from an url, my code works as intended but when I try to load the same library from my local drive it spits out the error:
Uncaught ReferenceError: quat is not defined
at main (main.js:3)
at onload (index.html?_ijt=h48f9s7rceh7l34tfquh6ab8n5:7)
main @ main.js:3
onload @ index.html?_ijt=h48f9s7rceh7l34tfquh6ab8n5:7
What am I doing wrong in second case?
//index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body onload="main()">
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js"></script>-->
<script src="Libraries/gl-matrix.js"></script>
<script src="main.js"></script>
</body>
</html>
//main.js
function main()
{
let x = quat.create();
console.log(x);
}
html
I just copy/pasted your code to local files and run them.x
was logged successfully and the error you reported did not appear. I can't reproduce your problem with the code you provided.
– Quentin
Jan 3 at 11:27
this code with url works but I want this to work only with local. I mean this code spits error when I comment url part and uncomment local loading part. I do not understand why. I am providing it with the same local file.
– Applik
Jan 3 at 11:40
Then the most likely reason is thatmain.js
is the wrong URL, but there's no way to test that from here.
– Quentin
Jan 3 at 11:41
if it was the case it would not work with the remote url case too.
– Applik
Jan 3 at 11:45
Why wouldmain.js
being the wrong URL makehttps://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js
the wrong URL? I can loadhttps://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js
and clearly see that it is a JS file.
– Quentin
Jan 3 at 11:46
|
show 1 more comment
When I load the library from an url, my code works as intended but when I try to load the same library from my local drive it spits out the error:
Uncaught ReferenceError: quat is not defined
at main (main.js:3)
at onload (index.html?_ijt=h48f9s7rceh7l34tfquh6ab8n5:7)
main @ main.js:3
onload @ index.html?_ijt=h48f9s7rceh7l34tfquh6ab8n5:7
What am I doing wrong in second case?
//index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body onload="main()">
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js"></script>-->
<script src="Libraries/gl-matrix.js"></script>
<script src="main.js"></script>
</body>
</html>
//main.js
function main()
{
let x = quat.create();
console.log(x);
}
html
When I load the library from an url, my code works as intended but when I try to load the same library from my local drive it spits out the error:
Uncaught ReferenceError: quat is not defined
at main (main.js:3)
at onload (index.html?_ijt=h48f9s7rceh7l34tfquh6ab8n5:7)
main @ main.js:3
onload @ index.html?_ijt=h48f9s7rceh7l34tfquh6ab8n5:7
What am I doing wrong in second case?
//index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body onload="main()">
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js"></script>-->
<script src="Libraries/gl-matrix.js"></script>
<script src="main.js"></script>
</body>
</html>
//main.js
function main()
{
let x = quat.create();
console.log(x);
}
html
html
edited Jan 3 at 11:57
Applik
asked Jan 3 at 11:16
ApplikApplik
1219
1219
I just copy/pasted your code to local files and run them.x
was logged successfully and the error you reported did not appear. I can't reproduce your problem with the code you provided.
– Quentin
Jan 3 at 11:27
this code with url works but I want this to work only with local. I mean this code spits error when I comment url part and uncomment local loading part. I do not understand why. I am providing it with the same local file.
– Applik
Jan 3 at 11:40
Then the most likely reason is thatmain.js
is the wrong URL, but there's no way to test that from here.
– Quentin
Jan 3 at 11:41
if it was the case it would not work with the remote url case too.
– Applik
Jan 3 at 11:45
Why wouldmain.js
being the wrong URL makehttps://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js
the wrong URL? I can loadhttps://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js
and clearly see that it is a JS file.
– Quentin
Jan 3 at 11:46
|
show 1 more comment
I just copy/pasted your code to local files and run them.x
was logged successfully and the error you reported did not appear. I can't reproduce your problem with the code you provided.
– Quentin
Jan 3 at 11:27
this code with url works but I want this to work only with local. I mean this code spits error when I comment url part and uncomment local loading part. I do not understand why. I am providing it with the same local file.
– Applik
Jan 3 at 11:40
Then the most likely reason is thatmain.js
is the wrong URL, but there's no way to test that from here.
– Quentin
Jan 3 at 11:41
if it was the case it would not work with the remote url case too.
– Applik
Jan 3 at 11:45
Why wouldmain.js
being the wrong URL makehttps://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js
the wrong URL? I can loadhttps://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js
and clearly see that it is a JS file.
– Quentin
Jan 3 at 11:46
I just copy/pasted your code to local files and run them.
x
was logged successfully and the error you reported did not appear. I can't reproduce your problem with the code you provided.– Quentin
Jan 3 at 11:27
I just copy/pasted your code to local files and run them.
x
was logged successfully and the error you reported did not appear. I can't reproduce your problem with the code you provided.– Quentin
Jan 3 at 11:27
this code with url works but I want this to work only with local. I mean this code spits error when I comment url part and uncomment local loading part. I do not understand why. I am providing it with the same local file.
– Applik
Jan 3 at 11:40
this code with url works but I want this to work only with local. I mean this code spits error when I comment url part and uncomment local loading part. I do not understand why. I am providing it with the same local file.
– Applik
Jan 3 at 11:40
Then the most likely reason is that
main.js
is the wrong URL, but there's no way to test that from here.– Quentin
Jan 3 at 11:41
Then the most likely reason is that
main.js
is the wrong URL, but there's no way to test that from here.– Quentin
Jan 3 at 11:41
if it was the case it would not work with the remote url case too.
– Applik
Jan 3 at 11:45
if it was the case it would not work with the remote url case too.
– Applik
Jan 3 at 11:45
Why would
main.js
being the wrong URL make https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js
the wrong URL? I can load https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js
and clearly see that it is a JS file.– Quentin
Jan 3 at 11:46
Why would
main.js
being the wrong URL make https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js
the wrong URL? I can load https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js
and clearly see that it is a JS file.– Quentin
Jan 3 at 11:46
|
show 1 more comment
2 Answers
2
active
oldest
votes
Your main.js file is loading before the main plugin script loading change the order like this.
<script src="Libraries/gl-matrix.js"></script>
<script src="main.js"></script>
1
That doesn't matter sincequat
isn't accessed untilmain()
is called which doesn't happen until theload
event fires.
– Quentin
Jan 3 at 11:25
add a comment |
first, please try changing the order of your <script>
tags. Try loading the gl-matrix.js
file first. Additionally you should make sure to provide either an absolute path to your local gl-matrix.js
file or a path relative to the location of the file your <body>
tags are located in.
Best Regards,
Bachkippe
The order doesn't matter sincequat
isn't accessed untilmain()
is called which doesn't happen until theload
event fires.
– Quentin
Jan 3 at 11:26
The local gl-matrix file isn't loaded at all, the script elements are commented out. The library is loaded from a CDN.
– Quentin
Jan 3 at 11:26
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54021249%2floading-a-library-from-an-url-versus-local%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your main.js file is loading before the main plugin script loading change the order like this.
<script src="Libraries/gl-matrix.js"></script>
<script src="main.js"></script>
1
That doesn't matter sincequat
isn't accessed untilmain()
is called which doesn't happen until theload
event fires.
– Quentin
Jan 3 at 11:25
add a comment |
Your main.js file is loading before the main plugin script loading change the order like this.
<script src="Libraries/gl-matrix.js"></script>
<script src="main.js"></script>
1
That doesn't matter sincequat
isn't accessed untilmain()
is called which doesn't happen until theload
event fires.
– Quentin
Jan 3 at 11:25
add a comment |
Your main.js file is loading before the main plugin script loading change the order like this.
<script src="Libraries/gl-matrix.js"></script>
<script src="main.js"></script>
Your main.js file is loading before the main plugin script loading change the order like this.
<script src="Libraries/gl-matrix.js"></script>
<script src="main.js"></script>
answered Jan 3 at 11:24
sdebarunsdebarun
818
818
1
That doesn't matter sincequat
isn't accessed untilmain()
is called which doesn't happen until theload
event fires.
– Quentin
Jan 3 at 11:25
add a comment |
1
That doesn't matter sincequat
isn't accessed untilmain()
is called which doesn't happen until theload
event fires.
– Quentin
Jan 3 at 11:25
1
1
That doesn't matter since
quat
isn't accessed until main()
is called which doesn't happen until the load
event fires.– Quentin
Jan 3 at 11:25
That doesn't matter since
quat
isn't accessed until main()
is called which doesn't happen until the load
event fires.– Quentin
Jan 3 at 11:25
add a comment |
first, please try changing the order of your <script>
tags. Try loading the gl-matrix.js
file first. Additionally you should make sure to provide either an absolute path to your local gl-matrix.js
file or a path relative to the location of the file your <body>
tags are located in.
Best Regards,
Bachkippe
The order doesn't matter sincequat
isn't accessed untilmain()
is called which doesn't happen until theload
event fires.
– Quentin
Jan 3 at 11:26
The local gl-matrix file isn't loaded at all, the script elements are commented out. The library is loaded from a CDN.
– Quentin
Jan 3 at 11:26
add a comment |
first, please try changing the order of your <script>
tags. Try loading the gl-matrix.js
file first. Additionally you should make sure to provide either an absolute path to your local gl-matrix.js
file or a path relative to the location of the file your <body>
tags are located in.
Best Regards,
Bachkippe
The order doesn't matter sincequat
isn't accessed untilmain()
is called which doesn't happen until theload
event fires.
– Quentin
Jan 3 at 11:26
The local gl-matrix file isn't loaded at all, the script elements are commented out. The library is loaded from a CDN.
– Quentin
Jan 3 at 11:26
add a comment |
first, please try changing the order of your <script>
tags. Try loading the gl-matrix.js
file first. Additionally you should make sure to provide either an absolute path to your local gl-matrix.js
file or a path relative to the location of the file your <body>
tags are located in.
Best Regards,
Bachkippe
first, please try changing the order of your <script>
tags. Try loading the gl-matrix.js
file first. Additionally you should make sure to provide either an absolute path to your local gl-matrix.js
file or a path relative to the location of the file your <body>
tags are located in.
Best Regards,
Bachkippe
answered Jan 3 at 11:25
BachkippeBachkippe
4312
4312
The order doesn't matter sincequat
isn't accessed untilmain()
is called which doesn't happen until theload
event fires.
– Quentin
Jan 3 at 11:26
The local gl-matrix file isn't loaded at all, the script elements are commented out. The library is loaded from a CDN.
– Quentin
Jan 3 at 11:26
add a comment |
The order doesn't matter sincequat
isn't accessed untilmain()
is called which doesn't happen until theload
event fires.
– Quentin
Jan 3 at 11:26
The local gl-matrix file isn't loaded at all, the script elements are commented out. The library is loaded from a CDN.
– Quentin
Jan 3 at 11:26
The order doesn't matter since
quat
isn't accessed until main()
is called which doesn't happen until the load
event fires.– Quentin
Jan 3 at 11:26
The order doesn't matter since
quat
isn't accessed until main()
is called which doesn't happen until the load
event fires.– Quentin
Jan 3 at 11:26
The local gl-matrix file isn't loaded at all, the script elements are commented out. The library is loaded from a CDN.
– Quentin
Jan 3 at 11:26
The local gl-matrix file isn't loaded at all, the script elements are commented out. The library is loaded from a CDN.
– Quentin
Jan 3 at 11:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54021249%2floading-a-library-from-an-url-versus-local%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I just copy/pasted your code to local files and run them.
x
was logged successfully and the error you reported did not appear. I can't reproduce your problem with the code you provided.– Quentin
Jan 3 at 11:27
this code with url works but I want this to work only with local. I mean this code spits error when I comment url part and uncomment local loading part. I do not understand why. I am providing it with the same local file.
– Applik
Jan 3 at 11:40
Then the most likely reason is that
main.js
is the wrong URL, but there's no way to test that from here.– Quentin
Jan 3 at 11:41
if it was the case it would not work with the remote url case too.
– Applik
Jan 3 at 11:45
Why would
main.js
being the wrong URL makehttps://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js
the wrong URL? I can loadhttps://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js
and clearly see that it is a JS file.– Quentin
Jan 3 at 11:46