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

What is the offset in a seaplane's hull?

How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?

What defenses are there against being summoned by the Gate spell?

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

What do you call a Matrix-like slowdown and camera movement effect?

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

If Manufacturer spice model and Datasheet give different values which should I use?

Is it possible to make sharp wind that can cut stuff from afar?

How does one intimidate enemies without having the capacity for violence?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

How can I fix this gap between bookcases I made?

Example of a relative pronoun

What is the command to reset a PC without deleting any files

Prevent a directory in /tmp from being deleted

Is it possible to do 50 km distance without any previous training?

Could a US political party gain complete control over the government by removing checks & balances?

Japan - Plan around max visa duration

Copenhagen passport control - US citizen

My colleague's body is amazing

Why is "Reports" in sentence down without "The"

What would happen to a modern skyscraper if it rains micro blackholes?

Why has Russell's definition of numbers using equivalence classes been finally abandoned? ( If it has actually been abandoned).

How is this relation reflexive?

Should I join office cleaning event for free?



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 yesterday


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 yesterday


    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 yesterday


      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 yesterday


      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

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?