4

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>
ashish
  • 71
  • 1
  • 7

1 Answers1

8

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>
ravibagul91
  • 20,072
  • 5
  • 36
  • 59
  • 1
    did it but the it is not getting loaded . Nothing is showing up in network tab. – ashish Jun 13 '19 at 09:55
  • @ashish check in the source tab also. Also check your script file for any syntax error. – ravibagul91 Jun 13 '19 at 09:55
  • in the soure it is present and there is no error in the script . – ashish Jun 13 '19 at 10:33
  • so it means your `js` file is loading fine. check console for any error. check what functionality you wrote in that file is being executed. What error comes after executing that functions. – ravibagul91 Jun 13 '19 at 10:35