You are importing it, but not ‘using’ it, so it gets optimized out.
This is on the console, that wouldn’t work even if it did not get optimized out. If you want a module accessible at global level then you need to tell brunch where to put it (this is all normal brunch stuff, nothing at all to do with phoenix, you can use whatever packager you want if you don’t want brunch), so just add this to the npm config in your brunch-config.js file:
The globals says to take the jquery module and bind it to the global (browser window scope) names of $ and jQuery here.
Putting it in the global scope also prevents any of it from being optimized out (like if you add gcc as a prod optimizer), so you get the entire huge nasty bulk of jquery, even if you only use one tiny thing from it. It is good to minimize your globals for that reason.
For library that is not supported with Brunch, like CKEditor.
After place on /js/vendor/ and load correctly (Dev tools “Chrome/Sources”) how to “GET” references / secondary files without a phoenix route?
PS: If I place externally, like on a cdn, it works.
To get those libraries to work, Brunch has to be manually configured to associate certain modules with certain globals.
Then there is the problem that some older libraries won’t work with modern versions of jQuery.