JS file from directory not working

username - epiz_33896156

Website URL

https://leoam.app

Other Information

A JS file that I wrote that is integral to the functionality of my webpage does not seem to be loading. The Bootstrap JS CDN injection just before it in my HTML file seems to be functioning fine. Both of these JS files are loaded properly when working locally on my computer in pycharm.

Those lines of code at the end of the HTML file are below, and the local JS reference is where the trouble is coming from:

The filepath should be correct, is there something else that I am doing wrong?

here is the code:

<!-- JS CDN injection from https://getbootstrap.com/ -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>

<!-- local JS reference -->
<script type="text/javascript" src="https://leoam.app/htdocs/interactive.js"></script>

I see this

image

Likely due to

which I believe it should be https://leoam.app/interactive.js

2 Likes

that fixed it, you rule!

one thing i’m a little confused about - including htdocs in the filepath for a local CSS file seems to be working fine (see below), so why didn’t that work for the local JS file?

<html lang="en">
<head>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSS CDN injection from https://getbootstrap.com/ -->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">

    <!-- local reference styling -->
    <link rel="stylesheet" href="https://leoam.app/htdocs/additional_styling.css">

</head>

The htdocs folder is the files that contains the files of your website. It’s never included in the URL. If it was, you wouldn’t be able to view anything on example.com, only on example.com/htdocs/.

The only way your local file would work is if you created another directory called htdocs within you htdocs directory and uploaded the files to it.

Also, please note that hotlinking to files on our hosting is not allowed, so the local embed may stop working. But you could omit the domain name and protocol so you can just view the file locally with a local copy of the CSS.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.