Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress js/css en-queuing after wp_head() - leave inline/in footer, or worth modifying buffer?
    text
    copied!<p>I'm writing a plugin for Wordpress developers that allows a dev to include my own widgets in their theme at any point.</p> <p>The issue is that I can't control when they're going to require/use the widget code - which itself might necessitate the inclusion of external js/css files. </p> <p>I think it's likely that people will call these widgets often after wp_head() has executed, which means that any js/css inclusions that go with the particular widget they've called will get added inline (or, into the footer if i write it that way). </p> <p>I can't predict beforehand which widgets they might use to make sure the assets are included at an earlier juncture - and as far as i know, i can't ensure they end up in the [head] short of altering the output buffer with a preg_replace afterwards.</p> <p>So my question is really two-fold: If you were using the plugin, would you have a problem with potential assets for widgets (like carousels, etc) being loaded inline or in the footer? (I know non-critical js is often loaded in the footer, but have not seen a convention for doing this with css) And if so, is it worth altering the buffer with a preg_replace in order to fix this issue and ensure the externals end up in the [head]? Or perhaps a 3rd option I haven't thought of?</p> <p>The widgets themselves can be custom-made so i can't guarantee that any scripts that go with them aren't important enough to need to be loaded first (though it's unlikely) and i'm slightly concerned that altering the buffer after every page load would be inefficient.</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload