-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading JS help #14
Comments
@arbel Np! In order to use animejs locally through requiring it in the index.js, you need to install the package to node_modules in the project. So in the project terminal you'd run As for jQuery, it's a bit confusing and I don't fully understand it myself. Something to do with jQuery being a massive library and exporting itself as a global variable? I'm not entirely sure why it's so complicated. But basically we use it by putting the script in the It's best to cover all the bases and add externals: {
$: 'jquery',
jquery: 'jQuery',
'window.$': 'jquery',
} instead of just the one line you did. Some tools that use jQuery might use Hope that helps! |
Thanks for quick reply. I did what you said, the anime install went fine, and added the import line. but getting an this is my index.js import './index.html'; thanks! Idan |
You know what, I just tested it. If you call @shellscape, is there any chance you can shed some light on this since you've worked on Webpack? I'm seeming to have a fundamental misunderstanding of how Webpack works and it's really confusing me. I'm testing this on my personal site, so I actually use some of the things @arbel here is using. For example tilt.js. I thought the order of the imports in the But yet, when I download animejs, and I call it in the same Any insight would be greatly appreciated. Thanks |
@tr1s I'll do my absolute best to take a look at this today, and see if anything stands out. |
also tried loading lottie. tried btw, how do i know what to import? thanks |
Referencing this SO post: https://stackoverflow.com/questions/49451759/how-to-use-anime-js-or-any-external-library-in-a-vue-cli-project, and examining the default export for anime in both CommonJS and ESM, it looks like you're importing that correctly. Webpack will use anime.es.js, because it's defined with the |
i'm a beginner and apologize if this is a stupid question, but I don't completely understand how to load external and local scripts.
I was trying to include https://animejs.com/ into my site. I added an import in index.js to it. but kept getting an error that anime is undefined.
I ended up just adding
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/2.2.0/anime.js"></script>in my index.html file, but I think this is not the correct way.
Also couldn't quite understand what I had to do to load jquery.
added this to my index.html:
<script defer src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
and this in webpack.common.js
module.exports = {
mode: 'development',
entry: './src/index.js',
externals: {
jquery: 'jQuery'
},
jquery seems to work, but i'm not sure I did it correct.
thanks
Iadn
The text was updated successfully, but these errors were encountered: