Skip to content

jQuery & AssetMapper #50733

Closed Answered by weaverryan
rwkt asked this question in Q&A
Jun 21, 2023 · 4 comments · 4 replies
Discussion options

You must be logged in to vote

Ah, I think I understand the situation: you want to use jquery AND have it become a global $ variable. Like Encore, when you import jquery, it doesn’t become a global variable (though Encore had the autoProvideJquery() method to fake / force this).

so yes, if you want a global variable, your solution is correct: import it then make it global via window.$ 👍

But the hope is that, instead of relying on global variables, you import jquery wherever you need it. So in each file (or, I think even online script tags with type=“module” this would work, though I’d minimize use of those), where you are referencing $, do:

import $ from ‘jquery’;

Cheers!

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@SaItiplouf
Comment options

Comment options

You must be logged in to vote
3 replies
@ghost
Comment options

@stof
Comment options

stof Jul 7, 2023
Collaborator

@rwkt
Comment options

Answer selected by rwkt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants