5 ms·
sigh... Yet another simple plugin which needs jQuery for something which could be done in vanilla JS and still need less LOC. Tim: A better approach would be t
by b3tta 14y ago
sigh... Yet another simple plugin which needs jQuery for something which could be done in vanilla JS and still need less LOC.
Tim: A better approach would be to iterate through all children and find the maximum using elem.offset(Height|Width).
Then create a new <style> in the head for your plugin if it doesn't exist and append a new rule like:
style.innerHTML += '#' + (elem.id || (elem.id = 'eq' + (Date.now() % 1e9))) + '>*{' + equalize + ':' + val + '}';
If you don't like this you could still use elem.style.(width|height) (and maybe even detach the container beforehand to prevent unnecessary reflows), which will be faster and doesn't require a 90KB lib.
- tsvensen 14y agoGood call on a non-js version, this was abstracted from some code for a larger project. When I find the time I'll update the repo with a branch for a non-jQuery version, but there are plenty of simple scripts out there. Also, jQuery is 32KB minified and gzip'd AND that's if it's not already cached. Using the Google CDN helps as well, chances are you may not even be downloading it. Not looking to get into a jQuery vs. js debate. "I don't always write jQuery, but when I do, I use Javascript"
- b3tta 14y agoI know that. In fact I use jQuery in almost every website I'm writing, because I need backwards compatibility with older browsers. But since I started working on a certain website which only supports IE9, I'm pretty much only using jQuery for $.fn.animation. I just feel like it's a huge waste of computing time. Apart from that I think it's important to write "cross-library" plugins.