I'm working on a Gatsby project. I am trying to figure out the best way to include external scripts in my application. Currently I have a 'assets' folder in my 'src' directory with my css and js files. I import all of the css files at the top of my layout component and this seems to be working fine. I then use react helmet in that same layout component to include all of my js files. I receive the following error message in the browser console:
The script from “http://localhost:8000/assets/js/plugins/jquery-2.2.4.min.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
SyntaxError: expected expression, got '<'
Here's the first 22 lines of my layout component:
import React from "react"
import { Helmet } from "react-helmet"
import "../assets/css/bootstrap.min.css"
import "../assets/css/fontello.min.css"
import "../assets/css/magnific-popup.min.css"
import "../assets/css/animsition.min.css"
import "../assets/css/style.css"
export default () => (
<div className="global-outer">
<Helmet>
<script
type="text/javascript"
src="../assets/js/plugins/jquery-2.2.4.min.js"
defer="true"
></script>
<script
type="text/javascript"
src="../assets/js/plugins/jquery.magnific-popup.min.js"
defer="true"
></script>