• Resolved hivizwebsolutions

    (@hivizwebsolutions)


    As far as I can tell, the code snippets created do not get saved as external files. That being the case, it is not possible to specify the $src parameter when enqueueing the script/style.

    That means you have no control over script/style load order/dependencies (+ every other benefit that comes with enqueueing).

    Is this actually the case, or am I missing something?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Can you clarify what situation you are using wp_enqueue_script/style in?

    If you add CSS or JS snippets, they are enqueued for you using wp_enqueue_* and an automatically generated src URL.

    Thread Starter hivizwebsolutions

    (@hivizwebsolutions)

    Thanks Shea,

    * “If you add CSS or JS snippets, they are enqueued for you using wp_enqueue_* and an automatically generated src URL.” << Can you provide an example of such an auto-generated src URL?

    * “Can you clarify what situation you are using wp_enqueue_script/style in?” << This is a specific example. In the tutorial, the main function is saved as an external script sheet called “global.js” which is then enqueued.

    Many thanks!

    Thread Starter hivizwebsolutions

    (@hivizwebsolutions)

    Hi Shea,

    Just following up on this ticket.

    Many thanks!

    Thread Starter hivizwebsolutions

    (@hivizwebsolutions)

    Actually, upon further investigation, I think my original question was misguided. I can see that anything put in a CSS snippet is loaded into a separate “query-string-modified-homepage file” (of the form: yourdomain.com/?code-snippets-css=1), and anything put in a JS snippet is loaded into, yet again, a separate “query-string-modified-homepage file” (of the form either: yourdomain.com/?code-snippets-js-snippets=head or yourdomain.com/?code-snippets-js-snippets=footer, depending on the load location).

    So when you say:

    If you add CSS or JS snippets, they are enqueued for you using?wp_enqueue_*?and an automatically generated src URL.

    do you mean that anything put inside JS snippets are loaded into the aforementioned “file”, and then enqueued via the wp_enqueue_scripts function and hook, something like this:

    function my_scripts_method() { 
        wp_enqueue_script( 'my-script', get_home_url . '/code-snippets-js-snippets=header'); 
    } 
    add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
    Plugin Author Shea Bunge

    (@bungeshea)

    Yes, that’s correct.

    Thread Starter hivizwebsolutions

    (@hivizwebsolutions)

    So the stylesheet/script inside the CSS/JS snippet is already enqueued by the way this plugin is designed. Got it.

    Will now close this ticket.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to Enqueue snippet?’ is closed to new replies.