Are there "problems" with jQuery's small ones?

2

For example, some parts of a website, I can not fully tinker with HTML, put the platform locked for "security" and do not let it modify, so I use jQuery / JavaScript to do the modification I need. Does this interfere with website performance? A lot or a little?

Example of a code I used now, just to insert an image:

$j('<img src="http://i.imgur.com/UgaMSoE.png"style="max-width: 1.5rem;"/>').insertBefore('section#desejos .mywish__header a svg');

I use codes like this from time to time (not too many, only once in a while), when you can not modify something that I need. Does this influence the site performance?

Is there any problem getting jQuery / JavaScript "small" codes?

    
asked by anonymous 29.05.2017 / 15:16

2 answers

5

Yes, there are SEO issues. Today load time counts for the page to be well ranked in the search engine.

This by itself should already be something to think about using jQuery. Even more so to make a single line to do something that can make it equal or simpler without jQuery.

Much does not interfere with overall performance, but interferes.

The only way to know if it matters is for you to do and test.

    
29.05.2017 / 15:31
0

You can use it without fear. This will not influence performance, there is only an initial overhead on the first load, where the jQuery Javascript file is going to be loaded. After this, the file will already be cached and there will be virtually no download cost .

Make sure you only use mined files in production, thus reducing the bandwidth required for download of these files.

In cases where you will only make a small change via jQuery , try using pure Javascript instead of loading jQuery just to insert content in the page for example.

Below an HTML insertion code on page with pure javascript:

var newItem = document.createElement("LI");       // Create a <li> node
var textnode = document.createTextNode("Water");  // Create a text node
newItem.appendChild(textnode);                    // Append the text to <li>

var list = document.getElementById("myList");    // Get the <ul> element to insert a new node
list.insertBefore(newItem, list.childNodes[0]);  // Insert <li> before the first child of <ul>

This example was taken from the W3Schools website :

** Edited **

SEO , you should put Javascript files at the bottom of the page to prevent file loading from locking the page, thus causing site load delays. You can even request an analysis from Google to check the site and have some instructions to improve it. Clicking here you go to the Google review site.

    
29.05.2017 / 15:35