Enqueue conditional scripts only for the post

I just want to add some scripts to specific single post type . Exemple

function conditional_scripts()
    if ( is_singular( 'post' ) ) {
        add_action('wp_enqueue_scripts', function () {
        }, 100);

I try this in the setup.php but that’s not working. I can do it with the normal method of wordpress but i want to do it the best way possible.

Welcome! Look into dynamic imports. Here’s a simple example:

if (document.querySelector('.example')) {
1 Like