0

enter image description here

The above issues occur only on hard refresh(Ctrl+F5) and not on normal refresh(F5).

Can anyone help me to fix this?

  • You've to add dependencies to requirejs-config.js like below answer, try to implement external js in such a way @EjilarasanJ – Prathap Gunasekaran Apr 5 at 12:54
1

I have implement flexslider feature by the below way,

Try this,

First Step : Add the source files which is required for flexslider implementation.

  1. Add jquery.flexslider.js to the below path

app/design/frontend/{PackageName}/{ThemeName}/web/js/jquery.flexslider.js

  1. Add jquery.flexslider.css to the below path

app/design/frontend/{PackageName}/{ThemeName}/web/css/flexslider.css

then add css into your store

app/design/frontend/{PackageName}/{ThemeName}/Magento_Theme/layout/default_head_blocks.xml

then add the below code to it

<?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>
    <css src="css/flexslider.css" />
</head>
</page>

Second Step : Implementation of flexslider feature in to your store

  1. Add requirejs-config.js to the below path.

app/design/frontend/{PackageName}/{ThemeName}/requirejs-config.js

and add the below code in it

var config = {
paths: {
    'flexslider': 'js/jquery.flexslider'
},
shim: {
    'flexslider': {
        deps: ['jquery']
    },
}
};
  1. Final step is to trigger the js wherever you want in my case, I would need it in all the pages so I triggered it in header.phtml inside the theme.

Script to trigger the external js

require(['jquery','flexslider'],function($) {
$(window).load(function () {
     /*flexslider code*/
});
});

Hope it helps anyone, who's trying to add external js to their store. It would be any external script it may owl carousel or box slider js extension etc..,

Peace :)

  • Thanks a lot. Let me check the above points and reach you. – Ejilarasan J Apr 5 at 12:59
  • Not working as expected. Still, the issue exists. – Ejilarasan J Apr 5 at 13:51
  • Upgraded jquery-ui from 1.10 to 1.12 except the flexslider issue other issues have been resolved. – Ejilarasan J Apr 8 at 10:46

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.