Will jQuery affect my website loading speed?
Below are a few jQuery snippets that have helped us out a lot over the years. Especially when we bump into issues with plugins not allowing full customisation of certain elements. Instead of editing the plugin or theme files, we have been able to insert a quick snippet to solve our issue.
Don’t overwhelm your site with too much though! The odd bit of jQuery script added to the head or body of your website is not going to be a huge cause for concern. However, too much, and it can slow your site down in terms of website loading speed. If you have your website set up to load scripts in the footer then this will of course help greatly in preventing your code slowing down the page loading speed. In summary, it all depends on multiple factors: your website hosting, specific site setup and theme.
Tip 1: How to change the style of an element based on its text content
This one is extremely useful when, for example, a plugin or theme produces and outputs a bunch of elements (an array) using the same class and you wish to highlight a specific one. You may want to underline one of them or change the text colour, or highlight it bold. You have no tag handle like a class or id because the DOM is showing them all using the same name. Let’s show you what we mean.
Here is a list of elements in the DOM produced by say a plugin. On the left you’ll see how the code looks, on the right you’ll see what the user see’s on the page.