I am trying to add elastislide, for that, I added this code in phtml file

<div class="brand_block">
 <ul id="carousel_<?php echo $chunk2->getId(); ?>" class="elastislide-list"> 
<script type="text/javascript">
    function (jQuery) { 
         jQuery('#carousel_<?php echo $chunk2->getId(); ?>').elastislide(); 


I've added modernizr.custom.17475.js and jquery.elastislide.js in /app/design/frontend/vendor_name/theme_name/web/js folder

I am getting these errors in console

Uncaught ReferenceError: jQuery is not defined at jquery.elastislide.js:820 (anonymous) @ jquery.elastislide.js:820 (index):296 Uncaught TypeError: jQuery(...).elastislide is not a function

  • try replacing jQuery with $ in your script code
    – Piyush
    Aug 6, 2019 at 6:16
  • still getting same errors Aug 6, 2019 at 6:24

1 Answer 1


Your js/jquery.elastislide not recognizing jquery means you have not assigned shim that will create your js dependency to jquery in requirejs-config.js

Your code should look like in requirejs-config.js :

var config = {
    map: {
        '*': {
            'elastislide': 'js/jquery.elastislide'
    shim: {
        'js/jquery.elastislide': ['jquery']

You javascript function should look like this.

], function($){
    $('#carousel_<?php echo $chunk2->getId(); ?>').elastislide();

If you running production mode make sure deploy static content and clear cache.

php bin/magento setup:static-content:deploy
php bin/magento cache:clean

If you are in development environment you can just clear cache and changes will update.

php bin/magento cache:clean

Note you should also assign js/modernizr.custom.17475 in requirejs-config.js if its depends on jquery.

  • thank you but still getting same errors Aug 6, 2019 at 6:25
  • See i have updated answer
    – Aman Alam
    Aug 6, 2019 at 6:25
  • Do I have to put requirejs-config.js in app/design/frontend/vendor/theme/web ? Aug 6, 2019 at 6:33
  • 1
    You can put requirejs-config.js in app/design/frontend/vendor/theme
    – Aman Alam
    Aug 6, 2019 at 6:35
  • Thank you so much :) It worked Aug 6, 2019 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.