Client side theme script not loaded
-
I could hardly restrain myself from biting into my desk out of frustration yesterday, trying to use Masonry on a custom page. My theme script file (
nodebb-theme-themename/static/lib/themename.js
) is correctly listed inplugin.json
but not included in the minifiednodebb.js
.
On the other hand (which is what troubled me), when I tried to include a script in the page itself that loads Masonry from a CDN and just initializes a masonry object, it kept being undefined.So maybe someone can tell me what is wrong here:
$().ready(function(){ $.getScript("https://cdnjs.cloudflare.com/ajax/libs/masonry/3.3.0/masonry.pkgd.js", function(){ console.log('Script has been successfully loaded!'); }); var masonryTest = new Masonry(); });
that just gives
// Uncaught ReferenceError: Masonry is not defined // (anonymous function) @ VM162:2 // InjectedScript._evaluateOn @ VM117:883 // InjectedScript._evaluateAndWrap @ VM117:816 // InjectedScript.evaluate @ VM117:682
Go ahead, try it yourself in the console at my site.
I have the feeling I overlook the obvious... -
Just a thought... this look promising...
require(['https://cdnjs.cloudflare.com/ajax/libs/masonry/3.3.0/masonry.pkgd.js'], function(Masonry) { var masonryTest = new Masonry(); console.log(masonryTest); });
(Though I didn't pass a selector into the
new Masonry();
call, so it errors out, but that should help.) -
@julian, here it is. Thank you for your time!