• Resolved John

    (@dsl225)


    Hi,

    I’m getting excellent results using this plugin together with WP Fastest Cache and enabling only here CSS & JS minification and combine.

    I only had issues with Forminator forms not displaying and I excluded their JS files from mnification and combine by using:

    /plugins/forminator/(.*?).js

    Everything seems to work fine now but I see there are lots of other JS files under several sub-directories of the plugin, in addition to the 2 main at their root folder.

    Does the above exclusion line include all of them or only the 2 at root folder?
    If not, is there really a need to exclude all JS files of a plugin if it does indeed work apparently fine?

    Thanks!

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Gabe Livan

    (@gabelivan)

    @dsl225 the easiest pattern you could use in the exclusion textarea from “JavaScript Files Minification” is /plugins/forminator/

    I’ve just made a few tests (latest version of Forminator) and this pattern works very well, no matter how many levels you might have there (directories) or what extension it would have (all should have .js, but you never know, some plugins make changes and use .php as an extension).

    Don’t forget to clear the page caching (e.g. if you’re using a plugin such as WP Rocket) before you check out the updated source code.

    PS: I’m glad you’re getting results with the plugin! Hopefully, you will use it for the long term! Happy winter holidays!

    Thread Starter John

    (@dsl225)

    Really??? As simple as that? No more ending with (.*?).js ?
    And can do the same at Combine loaded JS box?
    Can apply this as general rule or do you mean only for Forminator?

    – in fact I don’t know which one of those settings is really needed as I tested by enabling/disabling both of them at same time, which is not very smart…

    And what about CSS? Can I use the same logic there, without (.*?).css ?

    I’m using your plugin together with WP Fastest Cache and works like a charm.
    In fact, I was using CSS/JS minification & combine at WPFC initally and your plugin only for unloading them for each page or posts. That was a lot of work initially but really worth the pain! Thanks to your excellent documentation and settings description I was really able to load/unload exactly what was needed for each page and get excellent loading times at a shared hosting account.

    I kept things that way for a while to see how it worked and now decided to disable CSS/JS minification and combine at WPFC, keep it only for caching and enable those with your plugin. I used the basic settings by following your descriptions and the overall speed increase was really seen immediately. WPFC is doing an excellent automated job with them but you can really see the difference when you switch here!

    Forminator was the only issue and also some glitches with the theme I’m running here that runs some JS at homepage that I also excluded. Other than that I can’t see any other issues and I’m now ready not only for the long run but also to replicate those settings at other sites!

    Plugin Author Gabe Livan

    (@gabelivan)

    @dsl225 It is that simple as the RegEx delimiter used for the exclusion is # so preg_match() would check #/plugins/forminator/# (if it contains “/plugins/forminator/”) and if it’s a match, it won’t minify the file. The same principle is applied to the CSS files. Of course, the rule is simple as it looks for anything that contains the string. If you have something like /wp-content/themes/your-theme-dir/sources/plugins/forminator/file.js it will be a match, but you know you won’t have anything like that.

    The RegEx pattern (if you’re familiar with Regular Expressions) can be modified as you wish. In most cases, it’s that simple. To keep things easier for everyone the default # is used and so far it worked well. The Pro version which has Unload via RegEx allows you to set any delimiter you wish as some developers would want more flexibility with that. In most cases, this easy way works well!

    One thing to pay attention to is the ending forward slash. If, for instance, you just put /plugins/woocommerce (without the slash) and you also add WooCommerce extensions to your site that have the plugin directory starting with “woocommerce-” then it will be a match and you might want the match to be for WooCommerce (without any of its extensions).

    PS: You seem surprised that the rule can be simple. Only JS files are checked when you put rules there (same goes for the CSS files). If you put /plugins/forminator/ in the JavaScript exclusion textarea it will only be applied for SCRIPT tags as that’s common sense. Let me know if anything is unclear and you need further assistance!

    Thread Starter John

    (@dsl225)

    Many thanks for your time Gabe, that’s clear enough and very convenient!

    Thread Starter John

    (@dsl225)

    One more question if you don’t mind:

    I noticed at the page speed waterfall that most JS and some CSS are loaded through the CDN I’m using (Bunny CDN) and I wonder whether I should use this address or not under
    “Enable CDN URL rewrite”? Most files related to Forminator and to the Theme that I already excluded from minification and combine are loaded from the CDN.

    I read the related docs in there but my CDN has not been installed by a third party plugin and has been directly configured at Bunny CDN. I see also that I have a folder named “wp-content/cache/asset-cleanup/” (both locally and at CDN) but I have only a single CDN URL for all files: mydomain-b-cdn.net and nothing specific to CSS or JS.

    Should I use there the CDN’s URL?

    Plugin Author Gabe Livan

    (@gabelivan)

    @dsl225 “Enable CDN URL rewrite” was implemented, because, sometimes, the URL that points to the files within /wp-content/cache/asset-cleanup/ was not automatically updated by the CDN plugin or hosting company. So, the users noticed that everything was loaded from the CDN apart from the caching directory files.

    One of the examples (at least at the time the feature was implemented) is KeyCDN. Users were installing https://en-gb.www.ads-software.com/plugins/cdn-enabler/ (“CDN enabler” plugin by KeyCDN) and it worked fine for all files. To work for files within /wp-content/cache/asset-cleanup (basically to make it compatible), you had to add the KeyCDN CDD CNAME to “Enable CDN URL rewrite”.

    One of the posts were this thing was discussed is the following: https://www.ads-software.com/support/topic/cdn-integration/

    Thread Starter John

    (@dsl225)

    Thanks for this.
    I understand, but which one is the “CDD CNAME” you mention?
    For Bunny, I only have a single URL “mydomain-b-cdn.net” for all files: images, CSS and JS are all loaded from there.
    Can I use this one?

    Plugin Author Gabe Livan

    (@gabelivan)

    @dsl225 it depends on how the structure of the URL is. If it’s the same for all the files, you can put something like //mydomain-b-cdn.net for both CSS and JS files as you have 2 fields there. Note that you should do it ONLY if it’s not already automatically appended to the cached files.

    Thread Starter John

    (@dsl225)

    OK, but how do I check whether it is or not “already automatically appended to the cached files.”?

    I have it now enabled and I can see in Gtmetrix waterfall some files with this structure:
    mydomain-b-cdn.net/wp-content/cache/asset-cleanup/….

    Should I also re-check the same without this option enabled and see whether I get the same file structure?

    Plugin Author Gabe Livan

    (@gabelivan)

    @dsl225 The structure you mentioned is right. The replacement has taken place (it only does in the HTML source, not the actual files as the paths to CSS backgrounds/fonts are relative). To check if it works, view the source of the page and open the URLs of those assets: e.g. //mydomain-b-cdn.net/wp-content/cache/asset-cleanup/item/thefilename.css – if it loads, all good, if not the CNAME might not be good. If you disable the option you might get the standard (not within the CDN) URL: //yourdomain.com/wp-content/cache/asset-cleanup/item/thefilename.css).

    Thread Starter John

    (@dsl225)

    Yep, that was OK then, files were loading correctly.
    But now I now unchecked this option to see what happens, cleared all caches, and I still get the folder /asset-cleanup/ loaded from the CDN. Same as with the option checked.

    That probably means that I don’t really need this option enabled, right?

    I’ll keep it as is, unchecked, for a while to see if it remains that way.

    Plugin Author Gabe Livan

    (@gabelivan)

    @dsl225 As I mentioned in a previous comment (Note that you should do it ONLY if it’s not already automatically appended to the cached files.), it’s already rewritten by a plugin/hosting or whatever configuration you already have. So you can disable it. I believe a post should be written about this and added to the documentation.

    Thread Starter John

    (@dsl225)

    Excellent, that was also my understanding but I had to check again as I didn’t do before enabling this options, so I had to revert back to previous state…

    Many thanks Gabe, got it.
    And yes, something about it in the docs won’t hurt I believe.

    Thread Starter John

    (@dsl225)

    Hi, may I ask you why in fact do we need sometimes to exclude JS files from minification and combine? I had to exclude yet another plugin in there (accordion plugin) and I wonder whether there is simply a limit in the amount of JS files that can be minified/combined or whether this is purely a question of quality of the code of those files?

    As I made some modifications at this website recently, I also tried to remove the exclusion for Forminator for testing and I noticed that it worked fine for about 24 hours and the forms vanished again after that period and I had to exclude them as previously to make them work correctly.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Excluding JS files’ is closed to new replies.