Hi guys, I think I saw it is possible before but now I can’t find a way to upload my JS file into my webflow project. Is there a way to do something like that?
1 Like
If you’re hosting with Webflow, you’ll add the code itself to the page (or site wide)
If you’re hosting externally, you can modify the files themselves.
I didn’t mean code. I need to upload js file (example: linesScript.js) in webflow and then call it via asset link. Is this possible?
1 Like
I found this in another similar inquiry:
Yes it is, first upload it to your assets as a txt file, then you would have to do something like this
<script>
fetch('**TEXT FILE LINK FROM WEBFLOW**')
.then(response => response.text())
.then(script => {
const scriptEl = document.createElement('script');
scriptEl.type = "text/javascript";
scriptEl.textContent = script;
document.head.appendChild(scriptEl);
})
.catch(error => console.error('Error loading script:', error));
</script>