magefan / module-rocketjavascript

https://magefan.com/rocket-javascript-deferred-javascript
Other
40 stars 8 forks source link

Question about bundling list #3

Closed Tjitse-E closed 5 years ago

Tjitse-E commented 5 years ago

Hi,

Thanks a lot for this module, so far it works great for us!

I've one question about the 'Include in bundling' list. How are we supposed to use this script? What's the PATH_TO_JS in a Magento 2 instance?

globalSrc = '';
jQuery('script').each(function(){
if (!jQuery(this).attr('src')) return;
var src = jQuery(this).attr('src');
if (src.indexOf('https://' + window.location.hostname) != -1 || src.indexOf('http://' + window.location.hostname) != -1) {
var src = (src.replace(PATH_TO_JS, ''));
globalSrc += "\n" + src;
}
})
console.log(globalSrc);

Thanks again.

magefan commented 5 years ago

Hello @Tjitse-E , thank you for your message regarding our Magento Rocket JavaScript / Deferred JavaScript Extension.

PATH_TO_JS - you need to replace it with a string of static content URL including language. E.g. 'https://domain.com/pub/static/version1549034518/frontend/Magento/luma/en_US/'

We have also updated read me file https://github.com/magefan/module-rocketjavascript/commit/8dc99a45808a2f8a68567f4c4fb407d3813404b1

Please let us know if it help.

Tjitse-E commented 5 years ago

@magefan thanks, this is working for me!

So the idea here is to find out -by using your script- which non default JS resources the Magento 2 store is using, and then add these to the 'include in bundling' configuration?

magefan commented 5 years ago

@Tjitse-E , exactly. We have some predefined scripts in 'include in bundling' but as you may have a custom theme or extension we have created this simple script to help.