I think this Resources tab need some improvements. Example, under JavaScript resources - I have no way of knowing whether I just do /Designs/web_resources/themes/js/example.js or /web_resources/themes/js/example.js and it will be easier to provide instruction.
I would recommend adding File Browser (magnify icon).
Resurrecting this post because I’m currently dealing with the inability to get a custom widget working because the “JavaScript resources” lacks resources. My widget requires a javascript placed at the end of the page, and there’s no way to get around the default method of loading the javascript tag at the top of the page.
If I had an option to place a “defer” in the script tag would help me out as well.
Those macro updates don’t actually go in Widget builder display template. They would go in a .vm file that you would place in rx_resources/vm directory on the server.
For Widget Builder widgets if you add a reference to the js file to the JavaScript resources, or CSS. Usually you would put the physical files in a sub directory of web_resources.
When the Widget is deployed, that javascript references will be listed as one of the Resources for the Widget. Any page that uses the Widget will then auto include the resources for the widget when it is previewed/published. You can see these resource files under /rxconfig/Resources. There should be a Resource file to match each Widget under /rxconfig/Widgets.
The Velocity macro’s in the article are what handles injecting all JavaScript and CSS into all Pages published by CM1. So if you follow the article and deploy those macros in a vm file, you can have all of your Javascript get rendered in the before body close and have it deferred, instead of putting everything in the the head.
The usefulness of creating a custom widget just got complicated very quickly, lol.
I don’t know when I can sit down and start this process, but when I do I’ll resurrect this thread again.
But… if there’s any way in a future update to have a checkbox for widget builder’s javascripts to be placed at the top or bottom… count this as a vote for that feature!
The checkbox is a good idea. I hadn’t thought of making the location configurable like that. Was leaning towards shifting everything to the Before Body close by default.
I didn’t mean to over complicate things for you, just letting you know that you have some options, and letting you know how the system works.
The simplest thing you could do for now would be to add the js to the Before Body Close in the Template or Pages that use the custom widget.
The only downside is that the system Resource manager won’t handle the dependency for you automatically.