Okay
  Public Ticket #1701506
admin-ajax.php and general template loading time
Closed

Comments

  • Gregor started the conversation

    Hi,

    I'm finalizing the page I'm working on and came to the point where some loading optimizations should be done. I found out, the pages loading times are in average between 5 and 10 seconds. When checking the request I found out the admin-ajax.php (/wp-admin/admin-ajax.php?action=dynamic_css&ver=4.9.8) alone takes about 50% of all loading time, and there are 2 identical requests. Please check attached screenshots for a refference. The response of those requests is a css, probably generated by the theme (according to css classes names)

    I checked your demo site (cesis.co) and there are no admin-ajax.php requests there. How can I disable them thus speed the site by 50% and what is causing them?

    Thanks!

  •  895
    TheFox replied

    Hello Gregor,

    If you have finished the site and will not edit the theme options then what you can do is copy all the css of this file in your child theme style.css and then disable the ajax loading of this file.

    If you disable the ajax loading of the theme options css file even if you change the color settings / font settings etc it won't change on your site.

    We also recommend autoptimize to optimize the loading speed.

    Do not hesitate to contact us if you have more questions.

    Have a nice day!

    Regards.


  • Gregor replied

    This is one way although not very user friendly. Isn't there a way to cache the theme css request? It is a huge overload to request for the same file over and over again if we exactly know when the content changed (on cesis settings save). If there is no autmoation possible a simple button in the admin besides the current "Save" would do the trick just as well.

    I believe intalling some plugins woudl speed the page up but if admin-ajax.php request takes 3-4 seconds that is something no plugin can fix. Please fix that issue since a template that loads 5-10 seconds is completely unacceptable. If anything else such loading times causes many visitors to leave the page.

    I really like the Cesis theme but if this issue is not going to be fixed I'm affraid I can't afford to use it in the future projects. I bought 3 licenses in the past 3 months and was planning to continue using the template on new sites but not with the current loading time.

    I also tested some other templates I'm using and none of them uses the admin-ajax.php in the frontend for css.


    I hope you can fix the problem and we can all use an otherwise very beautiful theme in the future!

    Best,

  •  895
    TheFox replied

    Hello Gregor,

    You have only 2 option if you want to have dynamically generated css, have it put directly in the page as a big style block or using dynamic loading with ajax.

    Also the 3-4 ajax loading is not normal, so this can be boosted with plugins.

    Our team is working to make an option to let the user switch to static css file when they have finished to edit colors settings, which will make the theme to load an additional css file that contains the css file that is generated in the dynamic.css file.

    Currently we don't have this option so we can help you set it if needed.

    Kind regards

  • Gregor replied

    Hi,

    For generating static file I presume I only need to open the request, save the response to a css file and include it (e.g. enqueue in the functions.php). Is that correct?

    When done, how do I disable loading theme css via the admin-ajax.php?

    Thank you,
    Grega


    p.s. an option to switch to static file would be great. When do you expect to have it implemented?

  •  895
    TheFox replied

    Hello Gregor,

    Yes, this is the way to do it.

    You need to de-register / de-queue the  "dynamic-css" file.

    We have a big update with a big new feature coming up tomorrow or after tomorrow then in the next update we will try to implement it.

    Do not hesitate to contact us if you have more questions.

    Have a nice day!

    Regards.

  • Gregor replied

    Please let me know how do I de-register the dynamic-css file. I suppose I do it in the theme's functions file, but what line do I need to add?

    Thank you,

    Grega

  •  895
    TheFox replied

    Hello Gregor,

    If you are using the child theme just add this in the functions.php

    add_action( 'wp_enqueue_scripts', 'remove_dynamic_css', 20 );
    function remove_dynamic_css() {
        
        wp_dequeue_style( 'dynamic-css' );
        wp_deregister_style( 'dynamic-css' );
    }

    Do not hesitate to contact us if you have more questions.

    Have a nice day!

    Regards.


  • Shukhrat replied

    Regarding this "If you have finished the site and will not edit the theme options then what you can do is copy all the css of this file in your child theme style.css and then disable the ajax loading of this file."

    Where do I need to copy from?

  •  895
    TheFox replied

    Check the source code of your page and search for dynamic.css

    Open the file and copy all the content in the child theme style.css file and then add the function we posted in our previous reply in the functions.php file of the child theme

    Do not hesitate to contact us if you have more questions.

    Have a nice day!

    Regards.