minify javascript

Posted in: Newspaper
Post count: 67

Hello team,

How to minify javascript files and css files. i see you demo and you guys are using minify js and css. how you do that in my website http://www.movzio.com google pagespeed suggest minify HTML,CSS and JS. and the second issue is admin-ajax.php load to slowly can you please suggest the solution 🙂

Thank you

-Mosam

Post count: 9544

For minification I only recommend the following, and DONE MANUALLY:
I use http://cssminifier.com/

1) remove all the comments in wp-config.php manually
2) minify the style.css file
3) minify the functions.php file
4) if not running mod_pagespeed which does it for you, then you might also consider, manually opening your main post template and remove all double spaces and comments.

these are probably the 3 most loaded files on a WordPress site, and minifying them can really help.

Also putting in your direct URLs for base URL and home URL in the wp-config.php file really helps by saving queries. Similarly direct link to your theme folder also saves queries. But that is a bit advanced. See the WordPress Codex for more info on this topic of optimizing the wp-config.php file for hard-coded PATHS on your domain.

You can *try* minification of the main java file (.js), but this doesn’t always work very well.

Try:
http://javascript-minifier.com/
http://refresh-sf.com/

Or, open the two “main” .js files and just remove all the commenting, if you want a quick and dirty optimization.

  • This reply was modified 11 years by simchris.
Post count: 67

Didn’t get you

Post count: 9544

If you don’t know how to edit files manually for the theme you should not attempt any minification. There is no plugin to do it properly, aside from some things which mod_pagespeed running on your server might help with.

If you’re new to HTML and webdev.

The way you “minify” a file is removing extra spaces and line breaks.

For example, open the style.css file in text editor/programmer tool (I use TextPad on Windows, and BBedit on Mac), copy all the text, paste into the CSS minifier (link provided in my prior post); hit minify button, then paste back into the style.css file.

That is what minification is. Plenty of tutorials on the topic online.

In WP config, comments looks like

/** Sets up WordPress vars and included files. */

I cover most of this in the pagespeed sticky topic from the past year using the theme. Might be worthwhile to read through that; perhaps going back to front for my later posts.

But basically, you need to manually edit the files you want to minify, then use a tool to “minify” them; then replace the files on server in theme folder, etc., with the optimized versions.

Minifying the style.css file is the simplest thing to start with.

Post count: 67

Hello i minify the css files but can you please tell me how i do Eliminate render-blocking JavaScript and CSS in above-the-fold content??

i follow this guide https://forum.tagdiv.com/how-to-make-the-site-faster/ but i can’t get the id which google page speed tell in results so please have a look in my site http://www.movzio.com and please tell me how i do render-blocking?

Thank you

-Mosam

Post count: 6600

Hi,

Try to use this ID’s, inpect your page source, like this: http://screencast.com/t/5cpXIhxoPDxN and also use the function to inspect scripts presented at the second point under the “Remove render blocking css/js – using the TagDiv Speed Booster plugin (Advanced Users)” in the guide: https://forum.tagdiv.com/how-to-make-the-site-faster/
Make sure you do this right.

Thanks

Post count: 67

this way i get css ids but how to get javascript id?? when i use your function.php code but i can’t get the id which google page speed tell in pagespeed results. and i edit td-speed-booster.php file and add this code $this->move_style_to_footer(‘jetpack_css-css’); but it didn’t work. 🙁 why??

  • This reply was modified 11 years by Mosamlife.
Post count: 1291

Hi,

You shouldn’t add the last -css, just “jetpack_css”.
Try to optimize by enabling the default plugins, enable the rest one by one and look for the js/css classes.
The Pagespeed test also penalizes your score if you have too many plugins.

Thank you, Emil G.

Post count: 67

wait let me try

Post count: 67

How to get javascript id?

Post count: 1291

Hi,

You have to use the function provided in the tutorial, you could try to play with the priority, some plugins may load after it and that’s why it doesn’t return all js – http://screencast.com/t/7fhfjttAT8

http://codex.wordpress.org/Function_Reference/add_action

Thank you, Emil G.

Post count: 67

hello Bro,

can you please tell me how to remove render-blocking JavaScript?

i try this guide but https://forum.tagdiv.com/how-to-make-the-site-faster/ does not help me this function i can’t the actual id of https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js?ver=1.11.1 and https://www.movzio.com/wp-content/plugins/NKS-subscription/js/nk-sub.min.js?ver=4.1. can you please tell me how i get the id and use in your speed booster plugin??

-Mosam

Post count: 67

Anyone reply ??

Post count: 6600

Hi,

Emil stated above that because of the the scripts are loaded after the function is executed then the id could be missing so as he also stated use this function reference: http://codex.wordpress.org/Function_Reference/add_action .. study it and try to set different priority for it so that it gets executed later.
If you can’t manage this on your own please get someone to help you with this as you need some advanced knowledge about this.

Thanks

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