Jump to content

How to defer JS and CSS on-load


Gauravk

Recommended Posts

Posted

Working on site speed optimization, found these remarks in almost all reports to defer 7 JS files and 7 CSS files.

Anyone can help adding asyc defer switch in below highlighted two lines.....? Thanks.

        {template="includeMeta" app="core" group="global" location="global" params=""}
        {template="includeCSS" app="core" group="global" location="global" params=""}
        {template="includeJS" if="theme.js_include != 'footer'" app="core" group="global" location="global" params=""}

        {template="favico" app="core" group="global" location="front" params=""}

Capture.JPG

Posted
2 hours ago, Gauravk said:

Working on site speed optimization, found these remarks in almost all reports to defer 7 JS files and 7 CSS files.

So far there are only setting solution for JS.

Customization - Themes - Edit your theme - Custom->'Javascript include location -> Just before </body> tag' - Save

Posted

Installing the google pagespeed mod for apache or nginx can improve the loading speed vastly.

It allows to deferr all the css and js without touching the templates. The only tricky part is to prohibit the editor script to be deferred.

 

Posted
14 minutes ago, Gnuru said:

Installing the google pagespeed mod for apache or nginx can improve the loading speed vastly.

It allows to deferr all the css and js without touching the templates. The only tricky part is to prohibit the editor script to be deferred.

 

You can show the site where this mod work?

Posted

Adlago: Moving the JS line didn't help much as homepage was fine but classifieds landing page hidden all images, may be my coder need some work around to test it again.

Gnuru: Like Adlago, I would love to see some pagespeed optimize IPB server to have more confidence in taking that big step.

Posted

Actually I don't have a pagespeed optimize IPB server, I just use the mod_pagespeed for reducing the image sizes and experimenting with some other features.

It works pretty well for my site (www.teramed.de). You have to be careful concerning the server cpu load.

What I know, is that you can defer javascript, but it will brake the ck-editor.

Posted

OK, That's even better. Do you mind explaining how you using mod_pagespeed w/o installing on the server? So we can actually test it before implementing it. Thanks.

Posted

 

4 hours ago, Gauravk said:

OK, That's even better. Do you mind explaining how you using mod_pagespeed w/o installing on the server? So we can actually test it before implementing it. Thanks.

I am sorry, but you need to install mod_pagespeed to use it. I will be happy to show my configuration and the installation steps.

Posted
7 hours ago, Gauravk said:

Adlago: Moving the JS line didn't help much as homepage was fine but classifieds landing page hidden all images, may be my coder need some work around to test it again.

JS before the /body tag is a small part of optimizing speed. I personally use this setting successfully. But before that, I load all resource and images in cookie free domain etc.

Speed optimization process involves a lot of analyzes and tests. It takes time, patience and a lot of reading of information.

Posted

I installed the mod_pagespeed on my server today and tried several variation of filters making very very marginal difference here and there. Overall pagespeed score drop from 80-77 and finally given up for today after so many filters permutation and combinations and in end switch off all filters and let it run at default ON mode. Pingdom and yslow is also same as before.

Appreciate if someone have proven filters working for IPB.....!

 

Capture.JPG

Posted

would like to know what your pagespeed configs are?

i seem to have similar issues with google reporting 8 css blocking scripts. 

purging pagesped cach directory i get 0 blocking scripts but after 12 hours i get 8 blocking scripts again

Posted

Hi Maidos, I am not using any filters and kept at stock mode: ON. I tried with filters and it was not doing any benefit. 

Even the pagespeed score decreased from 80 -77 but I still like it with mod_pagespeed as it doesnt hold the page until full load so it gives a slightly better user experience when user sees that something appear in 1-2 secs and then page fully loaded at around 3 ish second from Dubai.

Where is the pagespeed cache file located, may be I can try that today and also share what all filters you are using? 

  • Management
Posted

You can't really defer CSS loading as it would show a FOUC (flash of unstyled content) before rendering the page. Some of our JS needs to execute before the page is rendered to hide elements too otherwise there is a risk that the page changes quickly after loading. There is a theme setting to defer loading the JS if you need it.

Posted

heres my pagespeed config.

http://www.textsnip.com/h3jis1

takes average 2.8 seconds to load my front page

pagespeed cache are located under /shm/ where my rams are being stored for faster performance

hm regarding css blocking script i read this on debug, think i need to adjust my config further

<!--deadline_exceeded--><!--deadline_exceeded for filter CssFilter--><!--deadline_exceeded--><!--deadline_exceeded for filter CacheExtender--><!--deadline_exceeded for filter CssCombine-->

@Makoto if u have time could you check if my configs are ok? :D

Posted
1 hour ago, maidos said:

@Makoto if u have time could you check if my configs are ok? :D

I haven't done any serious testing with Google PageSpeed on IPS4 yet.

When I do get around to it though, I'll be sure to post any findings and recommendations I have!

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...