Enqueue/Compile check

I use a locations plugin to manage multiple service area locations, very simple thing, but it works. Or rather, it worked until I began testing with beans, but I'm pretty sure I can use the Compiler to get it to work again. Reason why it doesn't work with beans, I'm not sure, something goes awry when I let it auto-compile (standard and aggressive). What happens is that a location page (custom post type) leaves a big blank area where the google map should be, but it doesn't generate it. So something is in the way, or not loading / being executed properly.

Scripts in question:

<link rel='stylesheet' id='stellar-places-css'  href='https://www.medischekeuringen.net/wp-content/plugins/stellar-places/assets/css/stellar-places.min.css?ver=1.0.3' type='text/css' media='all' />
<script type='text/javascript' src='//maps.googleapis.com/maps/api/js'></script>
<script type='text/javascript' src='https://www.medischekeuringen.net/wp-content/plugins/stellar-places/assets/js/stellar-places-map.min.js?ver=1.0.3'></script>

Using the following function I can enqueue css but also javascript.

add_action( 'wp_enqueue_scripts', 'my_function_name' );

function my_function_name() {

 beans_compiler_add_fragment( 'js_compiler_id', 'fragment_file_path' );


For js that comes down to beans_compile_js_fragments( 'js_compiler_id', array( 'file_path', 'file_path' ) ); correct? But why the double 'file_path'? I'm missing something.

So I found a clear article in the docs on compining assets, but I'm not sure on best practices (likely I'm not fully understanding some principles yet).

Here's the real question though, does it make sense to create a function for each such script? Or is it better to add each as a fragement within a custom function? If so, should I keep a custom function for css seperate from one for js?

Note on the side, if this works, it may very well be possible to overcome an annoyance with WP and JSON-LD (information layer, building on top of the schema markup for structure). As it is possible to embed it, beans should be able to enqueue and compile it. Think I'll do some experiments once I figure this one out properly.

for example <script type="application/json+ld" href="http://www.worldcat.org/oclc/7977212.jsonld"/>

Well, after much messing around I've found that applying it to json-ld scripts produces less than optimal results. Turns out that while as embedded script it works, it won't if compiled. Strangely enough, Yandex can read it that way, but they're the exception.

On the Location pages, no useful results either. I'm not sure why, if I use a local instance of google's map script it can work when compiled with the rest, but I'm hesitant to take that route - same for the stellar-places js. No issue with the css.

Write a reply

Login or register to write a reply, it's free!