Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

grozavule's avatar

jQuery and Vite

I've installed jQuery via npm. How do I get it to compile into the app.js file?

0 likes
2 replies
thinkverse's avatar

If you only write your jQuery inside your app.js file then you only need to import it.

import $ from "jquery";

If you need to write jQuery inline in a <script> tag, then you also need to add it to the window object.

window.$ = $;

Then if you need to write inline with a <script> tag, then the tag needs to be of type module.

<script type="module">
// $
</script>
grozavule's avatar

@thinkverse Thanks for your help. I never could get jQuery to work through the app.js file. I included it through a CDN just to move forward with my project.

Please or to participate in this conversation.