- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019
02:14 PM
10-14-2019
02:14 PM
Loading jQuery on specific pages
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.
Labels:
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019
08:58 PM
10-14-2019
08:58 PM
Re: Loading jQuery on specific pages
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.
---
If you've found my answer useful, please give"Kudos" and "Accept as Solution"
If you've found my answer useful, please give"Kudos" and "Accept as Solution"
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2019
12:04 AM
10-15-2019
12:04 AM
Re: Loading jQuery on specific pages
Follow Steps:
- Logged in to your backend and open that particular category where you would like to call that static block
- Click on Design tab of the category -> Find the Layout Update Xml -> Put below code in that. It will be your custom block on that particular category.
<referenceContainer name="main"> <block class="Vendor\Module\Block\YourBlock" template="Vendor_Mdule::yourTemplate.phtml"/>
</referenceContainer>
- Add your jquery code into above template.
Hope it helps!
If you've found my answer useful, please give"Kudos" and "Accept as Solution"