Plugin conflict with Compiler


I am having another issue with the compiler. Compiling the WordPress scripts is now breaking my slider, though I am not exactly sure why. The error I am getting is:

aa5d395.js:971 Uncaught ReferenceError: cffmetatrans is not defined
    at aa5d395.js:971
    at cff_init (aa5d395.js:1518)
    at aa5d395.js:1899

I found "cffmetatrans" in the plugin Custom Facebook Feed Pro, so that seems to be the source of the conflict. If I disable the plugin or set Beans not to compile the scripts, the issue goes away. Neither of those are a good solution, however, and I'm not sure what steps to take to try to resolve this. Any thoughts on this?

Also, is it possible to exclude this script from the compiler so I can keep my site functioning while this problem is investigated?


Hi Laura, the compiler is a gift that keeps on giving...

It might be that the plugin is not declaring all script dependencies correctly, resulting in cffmetatrans being called before it is defined. I don't see 'cffmetatrans' in the free version of the plugin and I have no access to the pro version so I can't confirm this guess.

There is a filter to remove scripts from the compiler, unforturnately it runs after the scripts are already removed and doesn't add them again.

On a slightly different note, if the website is using https or better the server has http/2 capabilities, I would run speed tests to confirm that using the compiler for JS files is actually faster than using a caching plugin or a plugin that asyncs/defers JS to the footer.


Yeah, it's the Pro version. I have a support ticket into them, so I'll follow up with them on that.

When you say the filter will remove scripts from the compiler and not add them again, you mean they will just run after (like they would without the compiler) or am I misunderstanding? If that's the case, what is the filter? I can't find it in the documentation.

The site is running on https, so I'll check that out as well.

Thanks!


The way the compiler works is that it makes a list of all the scripts that are enqueued to WordPress. It then removes/dequeues those scripts and compiles (really copies) the contents of those scripts into one file.

The filter runs after the scripts have been dequeued and before the files are copied which means that the script won't be available at all. You can find the filter here: https://github.com/Getbeans/Beans/blob/development/lib/api/compiler/class-beans-compiler.php#L199 It's not a solution for this case.

I was actually looking for a filter that would allow for what you want to do a few months ago and was surprised that it doesn't exist. Maybe we'll add one in the future.


Yeah, that filter would be handy! 🙂

Thanks again for your help!


This is the response I got from the plugin developer:

We show that that the Beans Framework is concatenating all of the JavaScript files and is loading them right at the top of the page header. This is causing the cffmetatrans variable to be undefined when it is called despite it being on the page lower down. Our plugin loads our JavaScript file after the cffmetatrans variable has been set and so it's defined by the time it runs, but now that the Beans Framework is loading our JavaScript file sooner then the variable isn't defined yet.

Would it be possible to load the Beans JavaScript file at the bottom of the element rather than at the top?

Is that possible?


If you change the compiler method to aggresive, it should move the JS to the bottom of the body.


Write a reply

Login or register to write a reply, it's free!