3 Replies - 380 Views - Last Post: 23 February 2016 - 11:15 AM

#1 howardbc14   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 109
  • Joined: 21-October 15

Optimal size of jQuery files

Posted 23 February 2016 - 01:57 AM

I am building a web page with the game Jeopardy! built into it. Right now, my jQuery file is 24KB and the browser freezes quite often. I checked my code repeatedly through the use of web developer tools and I am positive that no coding errors (never-ending while loops) exist. Thus, I was wondering if the file size could have anything to do with the browser freezing. Thus, I am wondering what the optimal size of jQuery files is.
Is This A Good Question/Topic? 0
  • +

Replies To: Optimal size of jQuery files

#2 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4303
  • View blog
  • Posts: 13,677
  • Joined: 08-June 10

Re: Optimal size of jQuery files

Posted 23 February 2016 - 02:21 AM

it’s not likely that the size is at fault. remote resources like script/style files and images usually get cached by the browser.

you would need to do some profiling on your code.

This post has been edited by Dormilich: 23 February 2016 - 02:21 AM

Was This Post Helpful? 0
  • +
  • -

#3 howardbc14   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 109
  • Joined: 21-October 15

Re: Optimal size of jQuery files

Posted 23 February 2016 - 11:09 AM

View PostDormilich, on 23 February 2016 - 02:21 AM, said:

it’s not likely that the size is at fault. remote resources like script/style files and images usually get cached by the browser.

you would need to do some profiling on your code.


So do you mean that I need to find ways to make my jQuery code more concise?

I am using functions for code that will be used across different situations to avoid code repetition by simply making function calls.
Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3134
  • View blog
  • Posts: 8,931
  • Joined: 15-January 14

Re: Optimal size of jQuery files

Posted 23 February 2016 - 11:15 AM

It really sounds like there's a loop or something. This isn't 2001 any more, the browser won't just pause while executing Javascript for no reason. It sounds like there is a loop that is tying the browser up. Using a code profiler will tell you what parts of the code take the most time to execute. Modern browsers have profilers built in to their developer tools to help you figure that out.

This has nothing to do with file size, I have applications that have well over 1MB of Javascript code and every modern browser will handle that just fine. It might take a couple seconds to download the code initially, but once that finishes it's not waiting for anything.

The other issue might be updating the page through the DOM. If you are doing a lot of updates to a lot of elements then the browser will spend time redrawing the page for each update.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1