Skip to content Skip to sidebar Skip to footer

How To Import Extremely Long JavaScript Const Into An HTML File

I have a JavaScript const that is a couple thousand lines long. When I include this constant, which is an array of objects, directly inside the tags in my index.html file, the con

Solution 1:

Inside your HTML:

<script type="module">
    import longJSON from './longJSON.js';
    console.log(longJSON);
</script

The longJSON.js

export default {
    some: 'super fancy content'
};

Information about modules: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules

with best regards


Post a Comment for "How To Import Extremely Long JavaScript Const Into An HTML File"