Okay
  Public Ticket #3075936
Java Script error when in WP Rocket
Closed

Comments

  •  2
    Dimitris Vayenas started the conversation

    Hello,

    When WP Rocket is activated, some users have reported this error: 

    jquery.min.js?ver=3.6.0:2 Uncaught ReferenceError: _ is not defined

        at wdtCreateSelectbox (wdt.frontend.min.js?ver=4.4:89:38)
        at Object.<anonymous> (wdt.frontend.min.js?ver=4.4:13:763)
        at Function.each (jquery.min.js?ver=3.6.0:2:3003)
        at s.fn.init.each (jquery.min.js?ver=3.6.0:2:1481)
        at HTMLTableElement.<anonymous> (wdt.frontend.min.js?ver=4.4:9:18)
        at Function.each (jquery.min.js?ver=3.6.0:2:3003)
        at s.fn.init.each (jquery.min.js?ver=3.6.0:2:1481)
        at $.fn.columnFilter (wdt.frontend.min.js?ver=4.4:8:58004)
        at wdtRenderDataTable (wdt.frontend.min.js?ver=4.4:456:88)
        at HTMLTableElement.<anonymous> (wdt.frontend.min.js?ver=4.4:487:184)


    Effectively the dataset is loaded fine, but the filtering selectors are not functioning at all.

    (see attached image)

    WP Rocket has issued a guidance about deferring JS Script of wpDatatables which I have followed but the problem persists.

    https://docs.wp-rocket.me/article/1560-delay-javascript-execution-compatibility-exclusions#wptemplate

    Please advise.

    Attached files:  wprocket-wpdatables-caching-error.png

  •   Dimitris Vayenas replied privately
  •  2
    Dimitris Vayenas replied

    This issue was solved by WP Rocket.

    It had to do with the underscore issue. 

    In WP Rockets exclude Javascript section the users have to add:

    /wp-content/plugins/wpdatatables/assets/js/wpdatatables/wdt.frontend.min.js(.*)

    In the Delay JS execution section the users have to add the following entries:

    /wpdatatables/
    /wp-includes/js/underscore.min.js

    The only issue that remains is that now the filters/selectors work fine, but the datatable/results are expanded - even though in the default case they ought to be "hidden".

    I have recorded a second video for you and WP Rocket in order to solve this issue too. 

  •   Dimitris Vayenas replied privately
  •  2
    Dimitris Vayenas replied

    I forgot to make explicit the other (obvious) issue. That apart from opening all the results during load, the filters are not working in the way they are supposed. So when I select a car, I do not get the options related to these cars only. Each filter is independent. 

    When I am logged in is working fine (see attached).

    Thank you. 

    Attached files:  Another-Issue.png
      How-it-actually-works-when-logged-in-uncached.png

  •   Dimitris Vayenas replied privately
  •  2
    Dimitris Vayenas replied

    Just to let you know that problem was solved by adding the following in the WP Rockets Deffered Delayed Execution Section

    wdt-master-detail
    wdt-powerful-filters
    wpdatatables
    /wp-includes/js/underscore.min.js(.*)

    See attached.

    Please provide it in your documentation.


    I also noticed that by adding in the Excluded JavaScript Files

    /wp-content/plugins/wpdatatables/assets/js/wpdatatables/wdt.frontend.min.js(.*)

     I get a 300-400ms additional delay.


    It will be great if your team can specify particular files to be deferred/excluded for optimal performance.

    Cheers!


    Attached files:  Related-rules.png
      excludedJS.png

  •  2
    Dimitris Vayenas replied

    Today, I had some complaints from the users that it wasnt working again.  I cleared the cache and now it works again. 

    I think you should look to it in more detail. 

    In the event that you do not have a WP Rocket plugin, I will be happy to provide one of my licenses. 

  •  1,689
    Miloš replied

    Hi, Dimitris 

    Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.

    -

    We currently have caching issues for all server-side tables;  such as SQL and Manual Tables.

    At this time, unfortunately, the only solution is to completely disable caching for pages where you have tables.

    Our developers are working to improve caching, as soon as possible, i can't say an exact ETA though.

    We apologise for this inconvenience.

    -

    Did you resolve the filtering issue - or is it still not giving you proper results?

    For the MySQL engine, we are dynamically adding the accent grave ( ` ), so there's no need to use it around the table name in the query. 

    If you were to delete them, searching and filtering should work just fine.

    Please check if you have the accent grave symbols around the table name.

    Let me know how it goes. Thank you

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  2
    Dimitris Vayenas replied

    Hi MIlos,

    Thank you for the tip. I just removed the ' and but the search is not working even in the uncached version. The datasource type is the SQL (it is direct access to a table I am preparing and gets updated every day). 

    With regards to the filtering issue in the WP Rocket caching, I think that the issue here is not your native caching (because your solution works fine when WP Rocket is not activated) but to help the WP Rocket guys issue the correct exceptions in their caching mechanism. I think that this might be an issue of the prioritazation of the javascript files in the build, even their sequence of exclusion/inclusion. I remember I had similar issues a few years ago when I bootstrapped your solution to the Metronic Theme. It may even be a case of CSS prioritazation that might need some tuning and or exceptions.

    Right now the solution seems to be working but I do not know if I find it working again tomorrow, possibly when the table gets recreated either your engine or WP Rocket has some issues with regards to caching and therefore I need to uncache everything etc. 

    Please look to it because WP Rocket great imporves the metrics of the application and it is a must have. 

  •   Dimitris Vayenas replied privately
  •  1,689
    Miloš replied

    Hi, Dimitris 

    Yes, please, that would be good.  I can investigate your site, with the help of our 2nd level Team.

    Please grant us temporary credentials for the WP Admin, but mark the response as private, of course - and if you can point out the table ID, just to be sure where to look.

    And if you can point out to the page where you placed the table shortcode, please.

    Thank you.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •   Dimitris Vayenas replied privately
  •   Miloš replied privately
  •   Dimitris Vayenas replied privately
  •   Dimitris Vayenas replied privately
  •   Dimitris Vayenas replied privately
  •   Miloš replied privately
  •   Dimitris Vayenas replied privately
  •   Miloš replied privately
  •   Dimitris Vayenas replied privately
  •   Dimitris Vayenas replied privately
  •   Miloš replied privately
  •  1,689
    Miloš replied

    Hi, Dimitris 

    The developers investigated this.

    They are not able to reproduce the issue - tried the site from the video,  as well as the site you have made;

    as logged in user;  but also from incognito browser tabs.

    They also tried different browsers, and they can't replicate the issue.

    Can you try to exclude the caching of the pages where the tables are,  in WP Rocket - since the issue is coming from there?

    Unfortunately, we are not familiar with WP Rocket's workings to the fullest extent, so we cannot determine exactly what the issue is.

    Sorry for the inconvenience.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  2
    Dimitris Vayenas replied

    Just to let you know that eventually I found the cause of the search issue.

    It may be good to keep in mind



    Attached files:  wpdatatables-ajax-searcherror.pdf

  •  1,689
    Miloš replied

    Hi, Dimitris 

    I am very happy to see that you isolated this issue.

    And i will also make sure to pass this to our developers, it will definitely be useful to be aware of, for other users who might experience the same issue, and save a lot of troubleshooting timesmile.png

    Thanks again.

    Of course, please don't hesitate to reach out to us with a new ticket for any new question , feedback, or issue.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables