Jump to content

Is jQuery as fast as JS?

Guest
Go to solution Solved by Alim,

90% jquery is already cached if you are using cdn

As I work on my website, I'm trying to make it as fast as possible. I used:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script><script src="js/fetch.js"></script>

On every page to load in the navbar and things not in my main_content section

fetch.js:

$(function(){  $("#include_navbar").load("template.html"); });

As you can see, this is jQuery. I know most of you with your fancy 100+ mbps would definently not notice a difference if I switched to js, but I think using jquery adds a ~100kb download to every page. So would it be worth it to switch to js? Also if it is, could someone convert the above jquery into js :P I'm not good at javascript. Thanks.

Link to comment
Share on other sites

Link to post
Share on other sites

in my experience no but then again im still learning jquery. pretty decent with javascript so it could just be that.

cpu: intel i5 4670k @ 4.5ghz Ram: G skill ares 2x4gb 2166mhz cl10 Gpu: GTX 680 liquid cooled cpu cooler: Raijintek ereboss Mobo: gigabyte z87x ud5h psu: cm gx650 bronze Case: Zalman Z9 plus


Listen if you care.

Cpu: intel i7 4770k @ 4.2ghz Ram: G skill  ripjaws 2x4gb Gpu: nvidia gtx 970 cpu cooler: akasa venom voodoo Mobo: G1.Sniper Z6 Psu: XFX proseries 650w Case: Zalman H1

Link to comment
Share on other sites

Link to post
Share on other sites

unless you are on #1mbitmasterrace you wont notice it

Well I am, so...

Link to comment
Share on other sites

Link to post
Share on other sites

speedtest?

1.2mbps/0.7

Link to comment
Share on other sites

Link to post
Share on other sites

dang.. but who is your website targeted at?

Anyone. It's mainly about programming/linux/3d modeling. Most of my friends and family live in the middle of nowhere so its important that I use as little bandwidth as possible without affecting the overall experience.

 

Also: when loading the sight it flashes for a second without css and its kind of annoying. Hopefully that is easily fixable.

Link to comment
Share on other sites

Link to post
Share on other sites

1.2mbps/0.7

btw i just discovered something: i loaded jquery.org with dev tools pulled up in chrome and it said jquery.min.js had a size of 0 so it's probably in cache which should mean it won't matter for loading speeds?

(i tried it again on my laptop and it said it was 32 kb (1.11.2))

Link to comment
Share on other sites

Link to post
Share on other sites

jQuery is a large library for JavaScript so of course you'll be adding some extra size to your page. You can customize it a bit to make it smaller though. See the Modules section here. Here is another option which simplifies the process. Using a good CDN (Google is just one option) will often improve things as well, and you can always get your own like CloudFlare.

 

Since jQuery is just a JavaScript library, for every piece of jQuery code there's an equivalent piece of JavaScript code. You don't need jQuery if you don't want to, it's just there to make things easier.

Link to comment
Share on other sites

Link to post
Share on other sites

Just throw async on to the script including tag and it won't load block unless you have a  terrible browser, so it's hardly noticeable

I am good at computer

Spoiler

Motherboard: Gigabyte G1 sniper 3 | CPU: Intel 3770k @5.1Ghz | RAM: 32Gb G.Skill Ripjaws X @1600Mhz | Graphics card: EVGA 980 Ti SC | HDD: Seagate barracuda 3298534883327.74B + Samsung OEM 5400rpm drive + Seatgate barracude 2TB | PSU: Cougar CMX 1200w | CPU cooler: Custom loop

Link to comment
Share on other sites

Link to post
Share on other sites

Just throw async on to the script including tag and it won't load block unless you have a  terrible browser, so it's hardly noticeable

Async is external scripts only

Link to comment
Share on other sites

Link to post
Share on other sites

Async is external scripts only

 

You're loading Jquery from google..? I'd say that counts as an external script 

I am good at computer

Spoiler

Motherboard: Gigabyte G1 sniper 3 | CPU: Intel 3770k @5.1Ghz | RAM: 32Gb G.Skill Ripjaws X @1600Mhz | Graphics card: EVGA 980 Ti SC | HDD: Seagate barracuda 3298534883327.74B + Samsung OEM 5400rpm drive + Seatgate barracude 2TB | PSU: Cougar CMX 1200w | CPU cooler: Custom loop

Link to comment
Share on other sites

Link to post
Share on other sites

You're loading Jquery from google..? I'd say that counts as an external script 

Oh thought you meant something else.

When I add it to that it just stops any css from loading

Link to comment
Share on other sites

Link to post
Share on other sites

jQuery is js.

 

And after the first page load it should be cached. If you use a popular cdn it could be even be cached from another site and wont slow down your site at all.

Link to comment
Share on other sites

Link to post
Share on other sites

Just realized I'll fix the flashing problem by moving the css links into invidividual files instead of the template

Link to comment
Share on other sites

Link to post
Share on other sites

Load the nav bar server side using PHP? if the server is building the site you will just have the html that is returned.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Load the nav bar server side using PHP? if the server is building the site you will just have the html that is returned.

I can't github pages is frontend only

Link to comment
Share on other sites

Link to post
Share on other sites

90% jquery is already cached if you are using cdn

Using Tapatalk

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

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

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×