Live data from Hacker News

Stop Paying Your jQuery Tax

samsaffron.com

71–80 of 90 posts

Re: Stop Paying Your jQuery Tax

#71
post #69
post #57

Earlier quoted context omitted.

I hate the whole web paradigm but it's what's in use and it's definitely improving. And in particular, jQuery makes it less painful so that's what many of us use (or similar JS frameworks). The same problem happens at the low end with the x86 instruction set. Yet we live with it. None of that makes it OK to write a bashful title that should've read "Stop paying your ASP MVC JS tax" or something. It all comes down on…

' None of that makes it OK to write a bashful title that should've read "Stop paying your ASP MVC JS tax" or something. ' "Bashful" means "shy," not "full of bash," as you seem to think. Actually, I wonder if you speak English natively as you seem to be the only person who interpreted the article the way you did.

You are right, I meant to use "bashing".

I do not speak english natively. But that has nothing to do with the bashing title. There is no "jQuery tax", that's a misleading statement.

Re: Stop Paying Your jQuery Tax

#72
post #42

Earlier quoted context omitted.

The DOM will have been parsed if your scripts are at the end—but external components (links, imgs) may not have loaded yet.

The same is true whether or not you use a document.ready statement; you're thinking of window.onready, which fires once all images have been downloaded.

you meant window.onload

Re: Stop Paying Your jQuery Tax

#74
post #68
post #37

Please go check out StackOverflow's source code before bandwagoning on this topic. This is shifting blame to the tools. The problem lies on StackOverflow's lacking design and not in jQuery. Pushing jQuery to the bottom of the page is trivial if you do proper HTML architecture. Pages should have only HTML. JS files only JS. JS files referenced at the very bottom of the body. Very simple. (if your asp/c#/* framework do…

Another telling gem is StackOverflow page doesn't even have a proper encoding declaration. They declare the encoding in the HTTP Response. Content-Type:text/html; charset=utf-8 That's totally proper. If you specify it again inside the HTML, are you gaining anything?

It's not wrong by itself, but making content encoding implied might become an issue later (e.g. load balancers or CDN, merging content or improving support on east-asian languages). It's likely they've never faced those kind of issues.

Re: Stop Paying Your jQuery Tax

#75
post #6
post #3

So is the article saying you are basically putting an alias for jQuery's `$` in the header and so if you need to put `$(function() {});` or `$(document).ready(function(){})` elsewhere in your page you rely on that alias and then once jQuery has loaded, map the `$` to it?

That is one technique you can use to assist you in pushing your jQuery include to the bottom, the others are having a smart script registration piece that takes care of it for you or running code that rewrites the html like blaze.io does

Complex solution to simple problems.

Re: Stop Paying Your jQuery Tax

#76
While I personally would prefer to put most JavaScript in an separate file, rather than sprinkled inline, it happens. So, why doesn't the browser handle this problem for us???

Why not have the browser drop all of the js script fragments and references into a queue, then run them later? Why make people reshuffle the stuff that they have working?

Hell, for that matter, I'm a bit puzzled why js even runs before the document is ready anyway. Is there some user in a hurry to get his alerts and popup windows?

Re: Stop Paying Your jQuery Tax

#77
post #71
post #69

Earlier quoted context omitted.

' None of that makes it OK to write a bashful title that should've read "Stop paying your ASP MVC JS tax" or something. ' "Bashful" means "shy," not "full of bash," as you seem to think. Actually, I wonder if you speak English natively as you seem to be the only person who interpreted the article the way you did.

You are right, I meant to use "bashing". I do not speak english natively. But that has nothing to do with the bashing title. There is no "jQuery tax", that's a misleading statement.

He doesn't suggest that there IS a "jQuery tax", rather that people's common misuse of jQuery imposes a tax on page rendering.

Re: Stop Paying Your jQuery Tax

#78
post #53
post #45

Earlier quoted context omitted.

Let's be clear ... I am not attacking jQuery here, just saying it is misuse to chuck it in the header and offering a practical mechanism to get out of a mess you create. I explain the cost of placing it in the header. I am not perfect, I make mistakes daily, I try to learn.

"Stop Paying Your jQuery Tax", that's an attention grabbing title with an attack on a free open-source project. It took you at least 20m to write that post, probably over an hour. You can't just say "oops".

1) If it took him a month to write that article, he could still say 'oops'. He's entitled to err.

2) It seems like you're the only one interpreting his post as an attack on jQuery. It isn't. You said in another thread that English isn't your first language. I'd suggest you temper your accusations in light of that knowledge.

3) Even if he were bashing jQuery, and even though it is a good and widely used framework, that's his right to do. Yes, it is your right to cry foul, as it is my right to attempt to set you straight.

Simply put, I think you're off the mark here. Your attack on him are more damning than his supposed attack on jQuery, and strikes me as defensive.

In with the good air, out with the bad.

Re: Stop Paying Your jQuery Tax

#79
post #2

That is a great point! An interesting question is, why not just put ALL scripts at the end of the tag, after the HTML of the page has loaded and the CSS probably did as well? The only thing I can think of is if you have code ON the page which uses these scripts. But why not just put that code at the end of the page, too?

A strong reason to not do so is when you want some part of the page to be immediately enhanced with JavaScript (like a login form). If the page has many images and other resources, your users will have an awkward experience, with the scripts suddenly engaging at a time that feels arbitrary. While some scripts absolutely belong at the bottom of the page, it is a very good idea to decorate JavaScript widgets immediatel…

Simply have the widgets start as display: none -- or even better -- visibility: hidden until they are rendered with js. The css accompanying the widgets should do this.

Re: Stop Paying Your jQuery Tax

#80
When we were working on WebPutty.net, we found headjs (http://headjs.com/) to be very useful for ensuring all other script calls are run outside of the tag. The full library runs 2.7k gzipped, while just the loader is 1.3k and is the only javascript file you need to block on. (The full script includes a modernizer library in addition to the script loading functionality.)
Post reply on HN