Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Eliminate render blocking Javascript and CSS

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #243751
    vivek Digarse
    Participant

    Hello guys , is there any one solution for “eliminate render-blocking Javascript and CSS”. i have faced this problem in every website when i complete it.
    http://prntscr.com/bvokqw

    #243753
    Shikkediel
    Participant

    Put the scripts at the bottom of the page – and ignore the CSS blocking (not really worth messing with in my opinion).

    #243766
    vivek Digarse
    Participant

    i have put the script at the footer.php and css in the header.php ,
    some script and css issue is sort out , but not sort out all script and css , is there any permanent solution for it ……hope reply.

    #243769
    Jerba
    Participant

    I assume you’re using WordPress… Those two files are effectively dependencies for WordPress and are loaded by WordPress itself when it needs them i.e. for the admin bar etc..

    #243770
    vivek Digarse
    Participant

    Yes , i am used WordPress…….”Eliminate render blocking Javascript and CSS” this issue is big problem for me….i want to more speed up website. because website speed is very important part…. i want permanent solution fot it.

    #243771
    Jerba
    Participant

    Okay, the only thing I can suggest you do is dequeue the jquery script that WordPress enqueues automatically and then whenever you’re ready i.e. the vast majority of the page has loaded re-enqueue it, but until you load it the admin ui will most likely be a little bit broken.

    Another possible solution is, filter into the script_loader_tag function which is what WordPress uses to output script tags and do the following:

    add_filter( 'script_loader_tag', function ( $tag, $handle ) {
        // this will currently add async to everything, so add conditions here where needed
        return str_replace( ' src', ' async src', $tag );
    }, 10, 2 );
    

    Which will effectively force the async attribute to be appended to the script tag .

    I hope this helped.

    Ref:
    https://developer.wordpress.org/reference/hooks/script_loader_tag/

    #243772
    vivek Digarse
    Participant

    Great! it ‘s help for me …….thanks.
    also any other suggestion please wrote in same.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.