Adding a JS file when a particular blade file is loaded on the page

Hey, I have recently discovered that we can pass variable inside a blade template like this,

@include('woocommerce.single-product.product-realted', ['id' => $p_id ])

Now, these are self-contained and reusable components for me.

I am interested in adding the required JS, for that particular page wherever it is required.

Right now I have to import it using JavaScript DOM-based routing.

Is it possible?

It would be a very elegant solution if it was.

This topic was automatically closed after 42 days. New replies are no longer allowed.