ashish
ashish

Reputation: 71

How to include custom script files in Create-react-app application

i have created a application using create-react-app now i need to include some of the script which i have like bootstap.min.js , jquery.min.js ,script.js , i have placed these files inside app/styles/js ans referencing them in index.html using script tag but if i do so i am getting Uncaught SyntaxError: Unexpected token < error in the console.

i have tried these solutions ,

ReactJS: "Uncaught SyntaxError: Unexpected token <",

if i reference using CDN it works fine but script.js is the custom create hense CDN is not available

<body>

<noscript>You need to enable JavaScript to run this app.</noscript>

<div id="root"></div>


   <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script> 
    <script src="../src/Styles/js/script.js"></script> //error here    
</body>

Upvotes: 4

Views: 7097

Answers (1)

ravibagul91
ravibagul91

Reputation: 20755

Create a js folder into public folder and put all your js file's into that js folder. And you can include that js file like,

<script src="%PUBLIC_URL%/js/script.js"></script>

Upvotes: 8

Related Questions