<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to get asset path in javascript? in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/How-to-get-asset-path-in-javascript/m-p/419588#M21811</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/174944"&gt;@jinwoooh&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;if you want to use an external JS file in a module/template I recommend you to use the &lt;A href="https://developers.hubspot.com/docs/cms/hubl/functions#require-js" target="_blank" rel="noopener"&gt;require_js function&lt;/A&gt;.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;How to get the asset path of your js file:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;copy/paste the URL(if it has one) into the require_js function and place this snippet into the header/footer (where it should be placed) // most likely the easiest solution&lt;/LI&gt;
&lt;LI&gt;create a new js file in the design-manager and paste the whole js code into it - save it - right-click on the file and select "copy path" - place it into the require_js function // great if you wnat to modify the file; HubSpot will automaticly minify the file if it's not minified&lt;/LI&gt;
&lt;LI&gt;create a new js file locally and upload it to the file-manager(not design-manager) copy the path and place it the require_js function // it's okay but not really recommended since HubSpot won't minify it&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;There is another option but since this is quite "the worst way possible" I won't tell you&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hope this helps,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anton&lt;/P&gt;</description>
    <pubDate>Wed, 17 Mar 2021 19:31:38 GMT</pubDate>
    <dc:creator>Anton</dc:creator>
    <dc:date>2021-03-17T19:31:38Z</dc:date>
    <item>
      <title>How to get asset path in javascript?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-get-asset-path-in-javascript/m-p/419487#M21803</link>
      <description>&lt;P&gt;I need to implement animation on our website, and we are trying to use 3rd party library.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that I don't know how I can get the asset file path from a javascript file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that get_asset_url works on hubl, but it doesn't work on a javascript file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how to get an asset path from js file?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 15:01:14 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-get-asset-path-in-javascript/m-p/419487#M21803</guid>
      <dc:creator>jinwoooh</dc:creator>
      <dc:date>2021-03-17T15:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to get asset path in javascript?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-get-asset-path-in-javascript/m-p/419588#M21811</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/174944"&gt;@jinwoooh&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;if you want to use an external JS file in a module/template I recommend you to use the &lt;A href="https://developers.hubspot.com/docs/cms/hubl/functions#require-js" target="_blank" rel="noopener"&gt;require_js function&lt;/A&gt;.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;How to get the asset path of your js file:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;copy/paste the URL(if it has one) into the require_js function and place this snippet into the header/footer (where it should be placed) // most likely the easiest solution&lt;/LI&gt;
&lt;LI&gt;create a new js file in the design-manager and paste the whole js code into it - save it - right-click on the file and select "copy path" - place it into the require_js function // great if you wnat to modify the file; HubSpot will automaticly minify the file if it's not minified&lt;/LI&gt;
&lt;LI&gt;create a new js file locally and upload it to the file-manager(not design-manager) copy the path and place it the require_js function // it's okay but not really recommended since HubSpot won't minify it&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;There is another option but since this is quite "the worst way possible" I won't tell you&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hope this helps,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anton&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 19:31:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-get-asset-path-in-javascript/m-p/419588#M21811</guid>
      <dc:creator>Anton</dc:creator>
      <dc:date>2021-03-17T19:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to get asset path in javascript?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-get-asset-path-in-javascript/m-p/419590#M21812</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/17186"&gt;@Anton&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get that we can get a js file path, but I want to get a json file path that I uploaded to module/template from a js file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My js code looks like this,&amp;nbsp;&lt;/P&gt;&lt;P&gt;var st = bodymovin.loadAnimation({&lt;BR /&gt;container: document.getElementById('st'),&lt;BR /&gt;renderer: 'svg',&lt;BR /&gt;loop: true,&lt;BR /&gt;autoplay: true,&lt;BR /&gt;// animation file path&lt;BR /&gt;path: 'JSON FILE PATH HERE!!!!!!'&lt;BR /&gt;})&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I don't know what's the best way to get json file path from here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jinwoo&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 19:39:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-get-asset-path-in-javascript/m-p/419590#M21812</guid>
      <dc:creator>jinwoooh</dc:creator>
      <dc:date>2021-03-17T19:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to get asset path in javascript?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-get-asset-path-in-javascript/m-p/694041#M30429</link>
      <description>&lt;P&gt;I had the same issue, check it out here:&amp;nbsp;&lt;A href="https://medium.com/@elghorfi.med/get-shopify-asset-url-in-javascript-33dd5c6ff1d7" target="_blank"&gt;https://medium.com/@elghorfi.med/get-shopify-asset-url-in-javascript-33dd5c6ff1d7&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 23:45:12 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-get-asset-path-in-javascript/m-p/694041#M30429</guid>
      <dc:creator>MEl-ghorfi</dc:creator>
      <dc:date>2022-09-15T23:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to get asset path in javascript?</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-get-asset-path-in-javascript/m-p/695496#M30492</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/174944"&gt;@jinwoooh&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if get_asset_url doesn't work: &lt;BR /&gt;Try to write it like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{{get_asset_url('../../boilerplate/js/main.js')}}
&lt;/LI-CODE&gt;
&lt;P&gt;basically replacing the first folder with "..". This can help sometimes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another possible way could be to upload your JSON file to the file manager and get the URL from there.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anton&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 14:45:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-get-asset-path-in-javascript/m-p/695496#M30492</guid>
      <dc:creator>Anton</dc:creator>
      <dc:date>2022-09-20T14:45:35Z</dc:date>
    </item>
  </channel>
</rss>

