Tuesday 14 August 2018

How to Host CSS and JavaScript files on GitHub?

Okay, so you have a problem of slowing of your blog or website because of the server, which is not giving hand-holding support to loading of resources. This happens specially if you are using shared hosting.The reason could be your CSS or JavaScript which are putting lots of pressure on your server.

So you are looking for a CDN or a file hosting service which would be totally free of cost! And yes, you're on the right place. Here I will show you how to host CSS and JavaScript files on GitHub totally free.
host files free on GitHub gist

#STEP 1:

Create your GitHub account, if you don't have already.After that, Sign In.
Now go to GitHub Gist, or Google search- 'GitHub gist'. There you will see a option for creating a new gist as follows.
Creating new gist in GitHub.
Creating new gist in GitHub.

#STEP 2:

Add filename with extension and copy-paste your code there. You can also write description. Then create the gist by clicking  Public or Private buttons. Only difference is that private gists do not appear in search engines, but can be viewed by anyone if that person has URL of the gist.
This is more nicely illustrated in the picture below.
Create GitHub gist.

#STEP 3

Now when your'e done with step 3, click on RAW button headed right about the code.
GitHub gist code
Copy the raw URL and finally you can use it as normal script element like below.
<script src="https://gist.githubusercontent.com/BigBozzz/be07313132a5cc895e1cfacef8542f29/raw/c0d8bbe761fea5fb993c2ee2efaaf73982bd41f8/Simplefunction.js"></script>

Now this was one way. Another is to by creating repository. If you already have a file in repository, click Raw button to get the link to raw file.

So here you learned how you can host unlimited files free! Follow css-magz for more trips and tricks like this or at least remember this name so you can catch us back!

5 comments:

Comment something useful and creative :)