Problem with javascript in a textfile load

Hello
I have some problemes with a custom JS code
My js code is over 1000 charactere. It will be used only in the part of my website. Actually, if i load it in custom code overall part, its work.
The fact is that i only want to load it in some pages, and the code size is 1700 chr so i can’t put it on custom codes in the page setting.
I have put my code in a text field uploaded in media in webflow. datacharts1.txt
My js is the following : <script type="text/javascript" src="https://uploads-ssl.webflow.com/61b0f2fea1247b8781890d06/64589f3c5f4e302c36bc4348_datacharts1.txt" ></script>
The fact is that i have an error message “caught SyntaxError: Cannot use import statement outside a module (”
My original code was loaded in module js with import :

<script type="module">
 import { getGoogleSheetData } from 'https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@latest/src/datasources/google-sheet-data.js';
    import { Database, loadAllData } from 'https://cdn.jsdelivr.net/gh/sygnaltech/webflow-util@latest/src/modules/webflow-data.js';</script>

How can i manage this
If you have any idea :slight_smile:


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

Hi when you import a script you got to appen it wherever you want. Imoort dont works
Here is an exemple on my test site

the script : /

/ create a variable for the script
script = document.createElement(‘script’);
//get the url of the file in txt format on webflow site
script.src = “https://uploads-ssl.webflow.com/61f42c0fc9965060757687bf/6458c20e31db95d8cf498ee4_javascript-to-text.txt”;
document.body.appendChild(script);

// you can put it in the head too

The page text to java

the txt file juste console.log “hello I am external”

I think this will save you day. Note as ansered if this is the right solution.

Hmm i’am not sure i have well done.

Try changing type="text/javascript" to type="module".