I created one module and i want to add js file to that module but in DOM i am getting "404 not found" my file are

var config = {
    map: {
        '*': {
            test1: 'My_Helloworld/js/test1'


], function($) {
    "use strict";
        alert('Test JS');


<script type="text/javascript">
        $(window).load(function() {
                animation: "fade",
                controlNav: "thumbnails",
                slideshowSpeed: 2000,
                minItems: 2,
                maxItems: 4

3 Answers 3


Instead of require(['jquery','test1'],function($){... try it with this:

require(['jquery','My_Helloworld/js/test1'],function($){ ...

This way you won't need the requirejs-config.js file.

  • thanks marius this is helped me lot...but i am not understanding that what wrong with requirejs-config.js file Commented Jan 5, 2016 at 7:17
  • Me neither. If I find something I will post it here.
    – Marius
    Commented Jan 5, 2016 at 7:17
  • requirejs-config.js:: in my case it is somehow missing "/js/" part in the url, which is why it's throwing 404. Any idea? Commented Dec 20, 2017 at 9:01

you can get it in any .phtml file by path

<link rel="stylesheet" type="text/css" href="<?php echo $block->getViewFileUrl('Package_Module::css/flexslider.css')?>">

I hope this will help you.


Please compare your try with How to load custom module js file in magento 2?. still you get same error then please comment here. You can implement use shim to maintain jQuery dependency.

  • i followed this one only but unfortunately i was getting 404 error but marius answer solved this 404 not found error. Commented Jan 5, 2016 at 7:26

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.