J
johncoltrane
We started a project last week. JQuery was, as usual, mentioned both in
functional and technical specs in an attempt to reuse some older bits of
code and, supposedly, ease the job for everyone.
I was ready to accept this as I don't feel confident enough to start a
project at my day job all with my limited skills.
There is a carrousel at the bottom of the page. After a while looking
for a suitable JQuery-related plugin/tutorial I settled down for one
which had the exact same features as we had planned and that we had used
previously. After reviewing the code I had a bizarre impression: all the
dollar signs seemed completely useless.
It actually took me less than 10 mn to transform this heavily JQuery
reliant script into a straight "raw" script without adding more than a
couple of lines. JQuery was used only to query DOM elements by ID and
move around a couple of those elements. Every
$('#id').method();
was readily replaceable by a
var foo = d.getElementById('id'); // "cached" early on
foo.bar = 'value';
or some similarly simple code.
In 10 mn I was able to remove entirely any dependency on JQuery from the
whole project. That's 70 Kb less, and that's good for everyone involved
: lighter, faster, more compatible, more reliable, more readable...
Now, I don't want to fall in the trap of becoming too confident over
such a small win but shit, but it doen't feel that hard to learn to
write real "JavaScript" for simple tasks like that.
functional and technical specs in an attempt to reuse some older bits of
code and, supposedly, ease the job for everyone.
I was ready to accept this as I don't feel confident enough to start a
project at my day job all with my limited skills.
There is a carrousel at the bottom of the page. After a while looking
for a suitable JQuery-related plugin/tutorial I settled down for one
which had the exact same features as we had planned and that we had used
previously. After reviewing the code I had a bizarre impression: all the
dollar signs seemed completely useless.
It actually took me less than 10 mn to transform this heavily JQuery
reliant script into a straight "raw" script without adding more than a
couple of lines. JQuery was used only to query DOM elements by ID and
move around a couple of those elements. Every
$('#id').method();
was readily replaceable by a
var foo = d.getElementById('id'); // "cached" early on
foo.bar = 'value';
or some similarly simple code.
In 10 mn I was able to remove entirely any dependency on JQuery from the
whole project. That's 70 Kb less, and that's good for everyone involved
: lighter, faster, more compatible, more reliable, more readable...
Now, I don't want to fall in the trap of becoming too confident over
such a small win but shit, but it doen't feel that hard to learn to
write real "JavaScript" for simple tasks like that.