Loading scripts in the builder

Hey @charlie hopefully all good over there. I did some research but unfortunately couldn’t find what I’m looking for. Is there a way that I can load all my custom Javascripts in the page builder? When I’m in the header builder this is already happening but on the page builder or any other template builder I have used until now this is not happening. Would be great if this is possible. Will save a ton of refreshing and switching back and forth in browsers.

1 Like

All good out here, spring time friend. Hope you are well.

How are you loading in the scripts? wp_enqueue_scripts? The Global JS from the code editor?

Thanks Charlie, here also all good, although here it is good weather all year long we’re having rain today also not bad for a change.

I’m loading my scripts with a plugin called Advanced Scripts. And then yes it’s about seeing the changes I make in the code editor.

Good weather all year round, would love to get some of that.

I’m guessing that plugin is outputting the scripts in the body of the page content and we don’t render that for some reason. Where are the scripts loaded on the actual page? Can you control where these scripts are loaded? As in could you load it in the head and just set it as async? To clarify too, are you trying to load JS in the Cornerstone app itself, or the JS in the page you are editing?

Hey Charlie, yes you’re right the scripts are being output in the body of the page. It’s to load my dependencies so that I can see the result of my custom JS live in the builder. I attach a screenshot of the Advanced Scripts plugin where you can see which locations I’m able to load the dependencies. Thanks for looking into it and looking forward to the BETA release tomorrow!

1 Like

Man that’s plugin looks like exactly what I would like it be. You can even add in different modules.

I might just have to get the plugin to try it out. I’m spitballing, but these filters might work if wp_head did not.

x_before_site_end
cs_footer

1 Like

@charlie If you want, send me a url that you want to try it on and I can send you an activation code… only for tryout purposes of course :slight_smile:

I think I have an idea on what you need to do. Add another action for cs_before_preview_frame and keep the same action you have been using. The action referenced will run whenever you are in the Cornerstone Preview Frame. Appreciate the offer though, usually I can get plugins for free if I send the right email lol. If that doesn’t work I’ll checkout this plugin seems very useful if we can get it running.

1 Like

Hey @charlie sorry for the late reply and thanks for getting back at this. I must confess, that I don’t know where I should change add this exactly. Should I just put this in my child functions.php and if so, how exactly if you don’t mind to explain :slight_smile:

In that UI it looks like you can have multiple hooks. Keep the wp_head if that’s working and it’s where you want to load it. Also add cs_before_preview_frame as a hook. Let me know if I’m misunderstanding something with that UI as well. Have a great weekend!
image