Friday, July 19, 2019

How to override custom jquery.min.js file in drupal 8

Add your custom jQuery library in your mytheme.libraries.yml:
jquery-custom:
  remote: https://github.com/jquery/jquery
  version: "2.2.4"
  license:
    name: MIT
    url: https://github.com/jquery/jquery/blob/2.2.4/LICENSE.txt
    gpl-compatible: true
  js:
    js/jquery-2.2.4.min.js: { minified: true, weight: -20 }

Then override the core jQuery library in your mytheme.info.yml:
libraries-override:
  # Replace an entire library.
  core/jquery: mytheme/jquery-custom
How to Implement

How do I use a jQuery version different from the default one used by core???

Step 1:-  If we have a default jquery version in drupal 8 like..

Step 2:- we have to change this version how..??? 

let's start

Note:- My theme name is gift..
 
Goto + Theme(gift folder) + gift.info.yml + add code


libraries-override:

  # Replace an entire library.

  core/jquery: gift/jquery-custom 


    Now Goto + Theme(gift folder) + gift.libraries.yml + add code

  jquery-custom:
        js:
         js/jquery-2.1.4.min.js: { minified: true, weight: -20 }


Output:-

No comments:

Post a Comment

If you have any problem please let me know.