How to append CSS from GitHub with JavaScript?

I have tried this which fails without a console error; imported CSS won’t effect the JavaScript HTML file.

const cssElement = document.createElement("link");
cssElement.setAttribute("rel", "stylesheet");
cssElement.setAttribute("type", "text/css");
cssElement.setAttribute("href", "");

<link rel="stylesheet" type="text/css" href="">

Move your css file to another host, github is not for hosting assets.

1 Like

I don’t know any.

In your opinion, what should I search for in search engines like Google, Bing, DuckDuckGo etc. ?

  • asset hosting
  • asset cloud
  • css cloud
  • CSS-JavaScript hosting
  • small file raw hosting

What is the standard term if there is one?

You can store all assets on IONOS VPS for 1 GBP a month.

I rent web hosting services from and I have tried uploading the file to my web applications root directory and then load it domainless via the IP address.

cssElement.setAttribute("href", "http://IP_ADDRESS/css.css");

GET http://IP_ADDRESS/css.css net::ERR_ABORTED 403 (Forbidden)

No SSL certification == no way, so maybe I should put this on top of my Drupal website somehow?

IONOS seems to me like a web hosting service which will also require an SSL certification.

I don’t think it’s possible to get an SSL certificate for something like a CSS file on any hosting…

If you have an existing website that you can upload files to, then yes, put the files there.

SSL certificates apply to a domain, not to specific files. All you need to get one is a domain name and a web server. If you have those you can get an SSL certificate for free using Let’s Encrypt.

If you don’t want to deal with setting up a web server with SSL just to host a css file, you could use something like Azure Storage to host it.

1 Like

My main website does have paid SSL certificate and proper HTTPS configuration so yes I guess I’ll try to put the file there but I got to say this:
Namecheap “pushes” me to use a tool such as the nice tool CertSage for gratis SSL certificates up to this very moment and I am frustrated that some (many? most?) hosting comanies are not customer-friendly on that matter and just give gratis SSL certificates, or just price-in them to the final price and offer various questionable “SSL plans”.

IONOS is both web hosting and VPS vendor. And regarding SSL you can put Cloudflare in front and activate “flexible SSL”. Just one click.

But using normal web hosting, you normally do not have root access. You upload files to a public folder via FTP or similar. Never any problems when I run Drupal. But to be honest, I have forgot exact how I did it.