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;
}







-1















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);
}









share|improve this question

























  • 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 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


















-1















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);
}









share|improve this question

























  • 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 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














-1












-1








-1








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);
}









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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 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



















  • 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 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

















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












2 Answers
2






active

oldest

votes


















-1














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>





share|improve this answer



















  • 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



















-1














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






share|improve this answer
























  • 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












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
});


}
});














draft saved

draft discarded


















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









-1














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>





share|improve this answer



















  • 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
















-1














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>





share|improve this answer



















  • 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














-1












-1








-1







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>





share|improve this answer













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>






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 11:24









sdebarunsdebarun

818




818








  • 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














  • 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








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













-1














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






share|improve this answer
























  • 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
















-1














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






share|improve this answer
























  • 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














-1












-1








-1







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






share|improve this answer













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







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 11:25









BachkippeBachkippe

4312




4312













  • 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 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 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

ts Property 'filter' does not exist on type '{}'

mat-slide-toggle shouldn't change it's state when I click cancel in confirmation window