How to reduce javascript usage on web page?

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I've just discovered that there is a recommended KB amount per page for websites.  After using a web tool, my index page weighs in at 780kb ... I'm told it should be under 500kb.  Ideally under 150kb.  

It's all mostly java script, which I thought was just the make up of the page.  How can I reduce this number without simply scrapping half my index page?

The site is www.a-class-driving.com

Thanks in advance.
Photo of Will

Will

  • 252 Posts
  • 4 Reply Likes
  • unsure as always with such things

Posted 3 years ago

  • 1
Photo of Peter Sauer

Peter Sauer

  • 150 Posts
  • 65 Reply Likes
I wouldn't be too concerned, your load time is 3.5secs
here is a link to your page specs.
http://tools.pingdom.com/fpt/#!/cEbhds/www.a-class-driving.com
Photo of Gop

Gop

  • 7473 Posts
  • 2115 Reply Likes
Hello Will,

If you have lots of js I would consider transitioning to CSS solutions. Many are described and can be found on a web-search. Just do them on by one, as you discover new solutions. The page weights will drop using CSS and they are faster. 

Your page currently loads in a reasonable time and I also notice, through reading, the target time for page loading is trimming as the web develops. Some are now focusing on a page load time of less than a second. It's great to see that you're maintaining your design so that your site remains very efficient. Well done.. There are few site authors who follow this important recomendation
Photo of Will

Will

  • 252 Posts
  • 4 Reply Likes
Hi Gop

This is well beyond my understanding.  I read a few posts online looking up "transistioning to CSS solutions" and they seem to be talking about animation and a few pages I honestly had no idea what they were talking about.

I take it that changing JS to CSS is for those in the know.  Is there an easier way?  
Photo of Gop

Gop

  • 7473 Posts
  • 2115 Reply Likes
Hi Will,

The way to approach it is to look for CSS solutions for your various plugins that are currently in js, then change these out as you go.

There isn't a universal solution that would change all js to CSS.

You need to identify which plugins you have set that are js then search for a CSS solution to replace them. If the js is running aspects which you haven't specifically added, then you can't approach it that way. That's up to the providers of the functions. (Google, Yola etc)