I am trying to add new Elements in an HTML page body by using document.createElement via Javascript, I am doing this with few if/else case and function callings. All is working fine.
Recently I came to know that I can do this with JQuery, too. I have not done too much of coding yet so I was wondering which way is the best in terms of efficiency ? Using native DOM methods or using JQuery to add elements dynamically on the page?
I am trying to add new Elements in an HTML page body by using
Share
Using native JavaScript should be faster, because that’s what jQuery will use underneath all the padding.
What jQuery gives you is abstraction from the browser. Who’s to say that one browser hasn’t implemented
document.createElement? Then you have to write a lot ofif-then-elsecode for your DOM manipulation.jQuery comes at an efficiency price, but saves a lot of heartache and provides a lot of utility than writing your own native JS.