Support » Plugin: Cerber Security, Antispam & Malware Scan » jQuery is not defined if Autoptimize plugin aggregate js files

  • Resolved moonberry

    (@moonberry)


    Form’s protection stop working when Autoptimize plugin is enabled and aggregate js files. Cerber puts own javascript (from function cerber_antibot_code() ) code into footer before autoptimize aggregated scripts file (included Jquery) and throw error “jQuery is not defined”.
    In my opinion the best way to fix this problem is drop jQuery and rewrite that function in pure javascript. (not all themes use jQuery)

    • This topic was modified 1 year, 1 month ago by  moonberry.
    • This topic was modified 1 year, 1 month ago by  moonberry.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Gioni

    (@gioni)

    Thanks for telling me! I’ll look into it soon and probably there will be a solution. By the way, if a website on a modern hosting uses HTTPS, most likely it supports HTTP/2 and concatenation doesn’t make any sense anymore. Moreover, it wastes web server resources for handling concatenation. ๐Ÿ™‚

    if a website on a modern hosting uses HTTPS, most likely it supports HTTP/2 and concatenation doesnโ€™t make any sense anymore. Moreover, it wastes web server resources for handling concatenation

    That is actually debatable @gioni B-)

    Here’s some reading material on this very interesting topic;
    https://calendar.perfplanet.com/2015/packaging-for-performance/
    https://medium.com/@asyncmax/the-right-way-to-bundle-your-assets-for-faster-sites-over-http-2-437c37efe3ff
    https://css-tricks.com/http2-real-world-performance-test-analysis/

    frank (autoptimize developer)

    Plugin Author Gioni

    (@gioni)

    Thanks for the links, Frank. Unfortunately they are less valuable than they could be. The mentioned researches are simple synthetic tests in a synthetic environment that controversial and some of them are ridiculous. Who uses 1000 JS/CSS files on a web page? The 99% of the processing time on a typical NGINX powered server with HTTP/2 enabled is the process of rendering page by WordPress itself. Even if some good concatenation in a real situation, not in synthetic tests, saves let’s say 20 ms, it doesn’t help anyone. Look at the real situation. An average website with WooCommerce has terrible speed results like 1 second per a simple page on an empty website. With a bulky theme and bulky plugins the page generation time becomes inappropriate at all. Plus on top of that, rendering a real web page in a real client browser with all those damn stuff like facebook widgets, google analytics, social buttons and visual effects consumes about ten seconds to load. BTW, check how many scripts and styles are loaded from external sources. Who cares about milliseconds? You save milliseconds and get some pesky conflicts. IMHO, it does simply not worth it.

    Besides, my tests on my real web projects shows that using built in NGINX compression provides better performance than using pre GZIP compressed asset files saved on the disk with no NGINX compression. I used to use some nice minification plugins before HTTP/2 became available and it was not good experience in terms of JS dependencies and conflicts with other plugins.

    Anyway, you and I have good intentions, but guys you should accept that HTTP/2 kills the idea of concatenation and high performance algorithms of NGINX kill the idea of precompression.

    Finally, any plugin developer should correctly handle wp_enqueue_script( ‘jquery’ ) calls in other plugins.

    @optimizingmatters

    Well, the ebay use case is far from a simple synthetic test in a synthetic environment. In fact, do a view source on ebay.com and you’ll see they indeed do concatenation, for the reasons explained in the article ๐Ÿ™‚

    I’m not saying HTTP/2 is without merit (I love it and it’s one of the first things we tell our customers when doing optimization jobs), I’m not saying concatenation is _always_ the right thing to do (AO 2.4 will have an option to optimize but NOT aggregate), but saying concatenation is _always_ useless when on HTTP/2 is cutting of some corners. In performance there are no absolutes, there is only configuration, testing, tweaking, re-testing, not making assumptions and then some more testing :-p

    Finally, any plugin developer should correctly handle wp_enqueue_script( โ€˜jqueryโ€™ ) calls in other plugins.

    by default AO excludes js/jquery/jquery.js from optimization (aggregation), but users can change that and that can break things, obviously ๐Ÿ™‚

    I don’t use jQuery in my themes, so I dequeue this library. Not all servers support http2, that’s why style/script aggregation is important. Every request slowdown loading site. This is especially visible on mobile devices.

    Plugin Author Gioni

    (@gioni)

    Well guys, in this case, there are two options for now: 1) disable antispam or 2) don’t dequeue jQuery. A jQuery-less version will be developed sometime this year.

    @optimizingmatters Thanks Frank for the developing plugin thoroughly ๐Ÿ™‚

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘jQuery is not defined if Autoptimize plugin aggregate js files’ is closed to new replies.