Jump to content

How to optimize javascript files so my website loads faster?

Recommended Posts

Site URL: https://huntersgaragepa.com/

Hello!

My homepage loads slower than I would like, and I think that might have to do with my javascript files. I read somewhere that having the js files in the header area slows page load time because of the retrieval of js files before the content on the page. I have some javascript in Settings > Advanced > Code Injection > "header" and "footer". 

I would be very appreciative if you could help me or give me some advice. 

Thank you.

edit: It seems the javascript files that are affecting the load time of my website are from squarespace itself... I still would like to know if there is a better practice when adding little bits of javascript, like I have in "header" and "footer".

Edited by huntersgaragellc
Link to comment
  • 4 weeks later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

On 2/1/2022 at 9:32 AM, huntersgaragellc said:

Site URL: https://huntersgaragepa.com/

Hello!

My homepage loads slower than I would like, and I think that might have to do with my javascript files. I read somewhere that having the js files in the header area slows page load time because of the retrieval of js files before the content on the page. I have some javascript in Settings > Advanced > Code Injection > "header" and "footer". 

I would be very appreciative if you could help me or give me some advice. 

Thank you.

edit: It seems the javascript files that are affecting the load time of my website are from squarespace itself... I still would like to know if there is a better practice when adding little bits of javascript, like I have in "header" and "footer".

You might consider minifying your larger JS files so that the load time is decreased. There are plenty of free tools online that can do this for you. Here is one of my favorites: https://www.toptal.com/developers/javascript-minifier/

Link to comment

You are currently loading two different versions of jQuery which will slow down your site. Ideally you shouldn't need jQuery at all because most code can be written more efficiently in pure JavaScript, but you definitely shouldn't have more than one version on your site. For good security, ensure it is the latest version.

Improve your online store with our extensions.
About: Squarespace Circle Leader since 2017. I value honesty, transparency, appreciation and great design ♥.
Work: Squarespace Developer and founder of SF Digital, building the features Squarespace didn't include™.
Content: Links in my posts may refer to SF Digital products or may be affiliate links.

Buy me a coffee

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.