Hi!
How do you host a javascript so you can use it in Webflow? I tried using Github following the tutorial I found here on the forum but they seem to have changed/shut down. Could anyone help out?
Hi!
How do you host a javascript so you can use it in Webflow? I tried using Github following the tutorial I found here on the forum but they seem to have changed/shut down. Could anyone help out?
You can:
Upload a JS file as a .txt file in assets then load it with a type="text/javascript"
attribute added.
Use a CDN like jsdelivr that allows for github assets to be called via the cdn. See Features - jsDelivr
Use a hosting platform or any other CDN to serve the resource.
Hi webdev, I am not as technical as you are and donât know how to make it happen with the instructions you left. Can you please elaborate on how to use code that has over 10,000 characters? Thanks in advance.
Can you link to the code source so I can better advise? If itâs on Github thereâs a simple way and I can prepare a code for you that youâll just need to paste in Webflow.
Hi Vako, thanks for your feedback. Basically, I am looking to implement a code taken from Codepen. The problem is that the JS code is more than 10,000 characters long. Here is the link: https://codepen.io/sanprieto/pen/XWNjBdb
UPDATE: OK, this version is now correct.
Iâve uploaded the JS code externally. You can load it using this code:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r125/three.min.js" ></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/VolkerShmuley/interactive-particles/script.js"></script>
Paste this code in the body tag of the page.
Then youâll need to copy the remaining HTML and CSS snippets from the codepen. HTML should go inside the custom code embed element.
CSS should go in the head tag using the previous page settings method. Youâll need to wrap the CSS between these tags:
<style>
/* CSS code goes here */
</style>
I tried it. It works.
Hi Vako, Thanks for your help, it worked! Can you please share how you exported the code? Thanks in advance.
There are two steps:
Tried your first advice, after uploading txt file with some styles, webflow replaced all semicolons with dash. Is that normal?
We are discussing the hosting of JavaScript in this topic. Are you trying to use a text file for CSS styles?
Uploading a JS file as a .txt file with type=âtext/javascriptâ doesnât work for me. Did something change recently that made it stop working?
@Juan_Taylor - Check your asset in the browser to make sure it loads. Then review your scripts.
Iâve tried many things. The only thing that works is a JS file with this in it.
document.write(âThis is an external Javascript Example.!!!â);
OR just the document.write. So the console.log doesnât work Unless I have the dcoument.write. Nothing else works. And I donât need the type=âtext/javascriptâ to make it work.
I want to use MixItUp Multifilter. After confirming the standard MixItUp worked, I made a text file out of their JS file (out of the standard MixItUp) and uploaded it to Webflow assets, etc. And even that didnât work.
This works in an external JS file.
for(var i=1; i<=5; i++) {
alert(âAlertâ + i)
}
However, it doesnât work if I put the type=âtext/javascriptâ.
Reviewing your console is a good place to go for diagnosing issues.
Yes, Iâm using console.log. I just noticed that MixItUp Standard as a JS text file uploaded to Webflow assets works, but it only works without type=âtext/javascriptâ. Maybe thereâs something wrong with type=âtext/javascriptâ.
Iâm pretty sure on my end type=âtext/javascriptâ stops everything from working. Works fine without but doesnât work with it.
My MixItUp Multifilter JS file as a TXT is now working through Webflow Assets but only leaving out the âtype=âtext/javascriptââ.
Hello, I tried doing the same. I uploaded my file on GitHub but its showing error, feather not defined, the i commented the line "feather.replace() and the again its showing SmoothScroll is not defined. Can you please help.
https://cdn.jsdelivr.net/gh/ammar26627/newTestMint@main/script_v2.js