I want to load a jQuery script on my product pages or if it's possible, on a specific categories pages. For example if I have a category for books and another for posters I want to load a specific script on all book pages but not the poster pages.
I appreciate any help.
Hello @evan_mcclure
If you really want to go down the XML route and don't want to use Require JS you will need to use the following XML.
Create route_controller_controller
<head> <script src="*PATH TO YOUR SCRIPT" /> <!-- External scripts --> <script src="URL-HERE" src_type="url" /> </head>
Hope it helps.
Follow Steps:
<referenceContainer name="main"> <block class="Vendor\Module\Block\YourBlock" template="Vendor_Mdule::yourTemplate.phtml"/>
</referenceContainer>
Hope it helps!
If you've found my answer useful, please give"Kudos" and "Accept as Solution"