Add/call a js file only on the home page magento 2?Add facebook pixel code into magento 2Magento2 Add additional js files to home page onlyInclude javascript only on a pageAdd javascript library only on the category page?Layout Update XML doesn't properly work for the home pageHow redirect the “no-route” cms page to home page after 10 second (not through server side)Add Newsletter Modal popup to CMS home pageStatic blocks on home pageMagento 2 :: Creating and Customising home pageHow to Include CSS for Home Page only in Magento 2Add bxslider in magento 2 home page

In Japanese, what’s the difference between “Tonari ni” (となりに) and “Tsugi” (つぎ)? When would you use one over the other?

"to be prejudice towards/against someone" vs "to be prejudiced against/towards someone"

Test whether all array elements are factors of a number

What's the output of a record cartridge playing an out-of-speed record

Can I make popcorn with any corn?

Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?

What does it mean to describe someone as a butt steak?

Finding angle with pure Geometry.

Writing rule stating superpower from different root cause is bad writing

How can bays and straits be determined in a procedurally generated map?

Can I ask the recruiters in my resume to put the reason why I am rejected?

Mathematical cryptic clues

Theorems that impeded progress

Dragon forelimb placement

The use of multiple foreign keys on same column in SQL Server

How to write a macro that is braces sensitive?

Fencing style for blades that can attack from a distance

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

Arthur Somervell: 1000 Exercises - Meaning of this notation

What typically incentivizes a professor to change jobs to a lower ranking university?

Font hinting is lost in Chrome-like browsers (for some languages )

Is a tag line useful on a cover?

How old can references or sources in a thesis be?



Add/call a js file only on the home page magento 2?


Add facebook pixel code into magento 2Magento2 Add additional js files to home page onlyInclude javascript only on a pageAdd javascript library only on the category page?Layout Update XML doesn't properly work for the home pageHow redirect the “no-route” cms page to home page after 10 second (not through server side)Add Newsletter Modal popup to CMS home pageStatic blocks on home pageMagento 2 :: Creating and Customising home pageHow to Include CSS for Home Page only in Magento 2Add bxslider in magento 2 home page






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm using magento 2.



I would like to add or call a js file only on the home page , what is the best file to call it?










share|improve this question
















bumped to the homepage by Community 2 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.





















    1















    I'm using magento 2.



    I would like to add or call a js file only on the home page , what is the best file to call it?










    share|improve this question
















    bumped to the homepage by Community 2 hours ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

















      1












      1








      1








      I'm using magento 2.



      I would like to add or call a js file only on the home page , what is the best file to call it?










      share|improve this question
















      I'm using magento 2.



      I would like to add or call a js file only on the home page , what is the best file to call it?







      magento2 javascript






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 23 '16 at 9:38









      Rakesh Jesadiya

      30.1k1576124




      30.1k1576124










      asked May 11 '16 at 15:18









      alexcralexcr

      62262148




      62262148





      bumped to the homepage by Community 2 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 2 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Just create cms_index_index.xml file in layout folder of your theme/module with following content:



          <?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="yourfile.js" />
          </head>
          </page>


          It should work :)






          share|improve this answer























          • it doesn't properly works like this, I did the file as you said , and after I uploaded my js file into /pub/static/frontend/Venustheme/yume/en_GB/js folder , and also written the link as /pub/static/frontend/Venustheme/yume/en_GB/js/myfile.js into the code , but doesn't seems to work..

            – alexcr
            May 11 '16 at 15:45











          • The link should be only js/myfile.js

            – Ideo
            May 11 '16 at 15:53











          • tryed also like this , but still doesn't work..

            – alexcr
            May 11 '16 at 18:33











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f114944%2fadd-call-a-js-file-only-on-the-home-page-magento-2%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Just create cms_index_index.xml file in layout folder of your theme/module with following content:



          <?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="yourfile.js" />
          </head>
          </page>


          It should work :)






          share|improve this answer























          • it doesn't properly works like this, I did the file as you said , and after I uploaded my js file into /pub/static/frontend/Venustheme/yume/en_GB/js folder , and also written the link as /pub/static/frontend/Venustheme/yume/en_GB/js/myfile.js into the code , but doesn't seems to work..

            – alexcr
            May 11 '16 at 15:45











          • The link should be only js/myfile.js

            – Ideo
            May 11 '16 at 15:53











          • tryed also like this , but still doesn't work..

            – alexcr
            May 11 '16 at 18:33















          0














          Just create cms_index_index.xml file in layout folder of your theme/module with following content:



          <?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="yourfile.js" />
          </head>
          </page>


          It should work :)






          share|improve this answer























          • it doesn't properly works like this, I did the file as you said , and after I uploaded my js file into /pub/static/frontend/Venustheme/yume/en_GB/js folder , and also written the link as /pub/static/frontend/Venustheme/yume/en_GB/js/myfile.js into the code , but doesn't seems to work..

            – alexcr
            May 11 '16 at 15:45











          • The link should be only js/myfile.js

            – Ideo
            May 11 '16 at 15:53











          • tryed also like this , but still doesn't work..

            – alexcr
            May 11 '16 at 18:33













          0












          0








          0







          Just create cms_index_index.xml file in layout folder of your theme/module with following content:



          <?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="yourfile.js" />
          </head>
          </page>


          It should work :)






          share|improve this answer













          Just create cms_index_index.xml file in layout folder of your theme/module with following content:



          <?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="yourfile.js" />
          </head>
          </page>


          It should work :)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 11 '16 at 15:25









          IdeoIdeo

          1,732718




          1,732718












          • it doesn't properly works like this, I did the file as you said , and after I uploaded my js file into /pub/static/frontend/Venustheme/yume/en_GB/js folder , and also written the link as /pub/static/frontend/Venustheme/yume/en_GB/js/myfile.js into the code , but doesn't seems to work..

            – alexcr
            May 11 '16 at 15:45











          • The link should be only js/myfile.js

            – Ideo
            May 11 '16 at 15:53











          • tryed also like this , but still doesn't work..

            – alexcr
            May 11 '16 at 18:33

















          • it doesn't properly works like this, I did the file as you said , and after I uploaded my js file into /pub/static/frontend/Venustheme/yume/en_GB/js folder , and also written the link as /pub/static/frontend/Venustheme/yume/en_GB/js/myfile.js into the code , but doesn't seems to work..

            – alexcr
            May 11 '16 at 15:45











          • The link should be only js/myfile.js

            – Ideo
            May 11 '16 at 15:53











          • tryed also like this , but still doesn't work..

            – alexcr
            May 11 '16 at 18:33
















          it doesn't properly works like this, I did the file as you said , and after I uploaded my js file into /pub/static/frontend/Venustheme/yume/en_GB/js folder , and also written the link as /pub/static/frontend/Venustheme/yume/en_GB/js/myfile.js into the code , but doesn't seems to work..

          – alexcr
          May 11 '16 at 15:45





          it doesn't properly works like this, I did the file as you said , and after I uploaded my js file into /pub/static/frontend/Venustheme/yume/en_GB/js folder , and also written the link as /pub/static/frontend/Venustheme/yume/en_GB/js/myfile.js into the code , but doesn't seems to work..

          – alexcr
          May 11 '16 at 15:45













          The link should be only js/myfile.js

          – Ideo
          May 11 '16 at 15:53





          The link should be only js/myfile.js

          – Ideo
          May 11 '16 at 15:53













          tryed also like this , but still doesn't work..

          – alexcr
          May 11 '16 at 18:33





          tryed also like this , but still doesn't work..

          – alexcr
          May 11 '16 at 18:33

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f114944%2fadd-call-a-js-file-only-on-the-home-page-magento-2%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

          How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2

          Nissan Patrol Зміст Перше покоління — 4W60 (1951-1960) | Друге покоління — 60 series (1960-1980) | Третє покоління (1980–2002) | Четверте покоління — Y60 (1987–1998) | П'яте покоління — Y61 (1997–2013) | Шосте покоління — Y62 (2010- ) | Посилання | Зноски | Навігаційне менюОфіційний український сайтТест-драйв Nissan Patrol 2010 7-го поколінняNissan PatrolКак мы тестировали Nissan Patrol 2016рвиправивши або дописавши її