0

I am new to Magento. I need to include an external code into my store.

<script src='https://cdn.rawgit.com/michalsnik/aos/2.0.4/dist/aos.js' src_type="url" /></script>

I have included this above into app\design\frontend\MMtheme\framework\Magento_Theme\layout\default_head_blocks.xml but js file makes conflicts.

default_head_blocks.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<head>
    <css src="//fonts.googleapis.com/css?family=Open+Sans:400,600,300" src_type="url" />
    <css src="css/font-awesome.css" />
    <css src="css/grid.css" />
    <css src="css/modules.css" />
    <css src="css/style.css" />
    <css src="css/mega_menu.min.css"/>
    <css src="css/demo.css"/>



<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery-1.11.3.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/mega_menu.min.js"></script>
<script src="js/aos.js"></script>   

</head>

enter image description hereenter image description here

0

You did add the cdn script correctly, however, Reading the code for aos.js on github, i believe you will need to include it's dependencies and css as well because you are using the rawgit cdn, which may cause issues when dependencies are loaded trough a main file.

I would recommend just downloading the code instead of using a CDN for this.

Could you paste the conflict error?

  • Hi Radosav, Thanks for your answer. Conflict means no other js are not working the page contents are messed up. – Mohamedali Jinna Aug 22 '16 at 12:26
  • I have followed your suggestiona and now an error shows in console. Error: Mismatched anonymous define() module: function (){return function(e){function t(n){if(o[n])return o[n].exports;var i=o[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var... ans so on at final requirejs.org/docs/errors.html#mismatch var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id); in require.js – Mohamedali Jinna Aug 22 '16 at 12:29
  • is there anyone to help me?!!!! – Mohamedali Jinna Aug 23 '16 at 4:40
  • Can you please provide a snippet from default_head_blocks.xml where you include the scripts and a screenshot of the error you got when the conflict arose and after you included the dependencies? – Radosav Aug 23 '16 at 10:23
  • Radosav, I have edited my question with that xml snippet and added console error screen shot – Mohamedali Jinna Aug 23 '16 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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