cancel
Showing results for 
Search instead for 
Did you mean: 

How to make jquery plugin script tag public

SOLVED

How to make jquery plugin script tag public

Hi guys,

             here am faceing a issue with below tag. i.e

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

when am trying to add the above in my cms page the page messing with design. please check the below screenshot. if you observe header section. its was not loaded properly. no addtocart button and account linkns. so can any one guide me that how can i call this tag externally. or else any suggesions. can any one help me on this ?

 

Screenshot (56).png

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to make jquery plugin script tag public

Hello @bharath553 

 

In Magento2, jQuery is already available to use. So you don’t need to use external jQuery.

 

Just put the following code in your .phtml file to use jQuery.

 

<script>
   requirejs(['jquery'], function($){
       // Your Code
   });
</script>

Hope it helps.

---
If you've found my answer useful, please give"Kudos" and "Accept as Solution"

View solution in original post

2 REPLIES 2

Re: How to make jquery plugin script tag public

Hello @bharath553 

 

In Magento2, jQuery is already available to use. So you don’t need to use external jQuery.

 

Just put the following code in your .phtml file to use jQuery.

 

<script>
   requirejs(['jquery'], function($){
       // Your Code
   });
</script>

Hope it helps.

---
If you've found my answer useful, please give"Kudos" and "Accept as Solution"

Re: How to make jquery plugin script tag public

Hi @bharath553 

 

Magento has its inbuilt jQuery. Can you please confirm where you want to add this file?

 

In case if you want to add this in customer account section. You can create a file inside your theme:

app\design\frontend\vendorName\themeName\Magento_Customer\layout\customer_index_index.xml

and add below code in it.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    </head>
</page>

I hope it will help you.

 

Thanks

--

Problem solved?Please give 'Kudos' and accept 'Answer as Solution'.