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?
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?
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>
Seriously, what’s the official best practice to do this properly in 2025?
Still this? Character Limit
Hi @Ingo_Steinke
In most places I believe the character limit is 50k now.
Best practices-
Use Embed elements for;
- Inline CSS
<style>blocks that you want to apply at design-time - Inline SVGs
- Possibly JSON-LD that’s being emitted by collection lists
- Advanced component-integrated JS
Use the Page-level custom code area for page-specific <script> code, especially the before-/body section. Use the before-/head section for async scripts, and most SEO work like special METAs, open graph content, or special icon formats.
Use the Site-level custom code areas for anything that works across all pages.
For any serious coding, write your code in TypeScript, compile, unit test and host on a CDN, and reference into your site.
Here’s a framework I use for that purpose;